github.com/claudiodangelis/banco@v0.0.0-20231219182139-c31d5d844fe5/module/module.go (about) 1 package module 2 3 import ( 4 "github.com/claudiodangelis/banco/item" 5 "github.com/claudiodangelis/banco/module/bookmarks" 6 "github.com/claudiodangelis/banco/module/documents" 7 "github.com/claudiodangelis/banco/module/notes" 8 "github.com/claudiodangelis/banco/module/tasks" 9 ) 10 11 // Module for banco 12 type Module interface { 13 // Name of the module 14 Name() string 15 // Aliases of the module 16 Aliases() []string 17 // Singular name of the module 18 Singular() string 19 // NewItemParameters to be input when creating a new item 20 NewItemParameters() []item.Parameter 21 // UpdateItemParameters to be input when updating an item 22 UpdateItemParameters(item.Item) []item.Parameter 23 // SaveItem stores a new item 24 SaveItem(item.Item) error 25 // OpenItem opens the item 26 OpenItem(item.Item) error 27 // UpdateItem updates current item to next item 28 UpdateItem(current, next item.Item) error 29 // DeleteItem from the module folder 30 DeleteItem(item.Item) error 31 // Init initializes the module 32 Init() error 33 // List items 34 List() ([]item.Item, error) 35 // Summary of the module 36 Summary() string 37 // Wether or not the module supports templating 38 HasTemplates() bool 39 } 40 41 // All modules 42 func All() []Module { 43 return []Module{ 44 notes.Module(), 45 tasks.Module(), 46 bookmarks.Module(), 47 documents.Module(), 48 } 49 } 50 51 // All module names 52 func AllNamesWithTemplates() []string { 53 var names []string 54 for _, module := range All() { 55 if module.HasTemplates() { 56 names = append(names, module.Name()) 57 } 58 } 59 return names 60 }