github.com/taubyte/tau-cli@v0.1.13-0.20240326000942-487f0d57edfc/cli/commands/resources/library/types.go (about) 1 package library 2 3 import ( 4 repositoryCommands "github.com/taubyte/tau-cli/cli/commands/resources/repository" 5 "github.com/taubyte/tau-cli/cli/common" 6 libraryI18n "github.com/taubyte/tau-cli/i18n/library" 7 libraryLib "github.com/taubyte/tau-cli/lib/library" 8 repositoryLib "github.com/taubyte/tau-cli/lib/repository" 9 libraryPrompts "github.com/taubyte/tau-cli/prompts/library" 10 libraryTable "github.com/taubyte/tau-cli/table/library" 11 "github.com/urfave/cli/v2" 12 ) 13 14 type link struct { 15 common.UnimplementedBasic 16 cmd repositoryCommands.Commands 17 } 18 19 // New is called in tau/cli/new.go to attach the relative commands 20 // to their parents, i.e `new` => `new library` 21 func New() common.Basic { 22 l := link{} 23 24 l.cmd = repositoryCommands.InitCommand(&repositoryCommands.LibCommands{ 25 Type: repositoryLib.LibraryRepositoryType, 26 I18nCreated: libraryI18n.Created, 27 I18nEdited: libraryI18n.Edited, 28 I18nCheckedOut: libraryI18n.CheckedOut, 29 I18nPulled: libraryI18n.Pulled, 30 I18nPushed: libraryI18n.Pushed, 31 I18nRegistered: libraryI18n.Registered, 32 33 PromptsCreateThis: libraryPrompts.CreateThis, 34 PromptsEditThis: libraryPrompts.EditThis, 35 36 PromptNew: func(ctx *cli.Context) (interface{}, repositoryCommands.Resource, error) { 37 iface, resource, err := libraryPrompts.New(ctx) 38 return iface, Wrap(resource), err 39 }, 40 PromptsEdit: func(ctx *cli.Context, resource repositoryCommands.Resource) (interface{}, error) { 41 return libraryPrompts.Edit(ctx, resource.(wrapped).UnWrap()) 42 }, 43 PromptsGetOrSelect: func(ctx *cli.Context) (repositoryCommands.Resource, error) { 44 resource, err := libraryPrompts.GetOrSelect(ctx) 45 return Wrap(resource), err 46 }, 47 LibNew: func(resource repositoryCommands.Resource) error { 48 return libraryLib.New(resource.(wrapped).UnWrap()) 49 }, 50 LibSet: func(resource repositoryCommands.Resource) error { 51 return libraryLib.Set(resource.(wrapped).UnWrap()) 52 }, 53 TableConfirm: func(ctx *cli.Context, resource repositoryCommands.Resource, prompt string) bool { 54 return libraryTable.Confirm(ctx, resource.(wrapped).UnWrap(), prompt) 55 }, 56 }) 57 58 return l 59 }