github.com/taubyte/tau-cli@v0.1.13-0.20240326000942-487f0d57edfc/cli/commands/resources/website/types.go (about)

     1  package website
     2  
     3  import (
     4  	repositoryCommands "github.com/taubyte/tau-cli/cli/commands/resources/repository"
     5  	"github.com/taubyte/tau-cli/cli/common"
     6  	websiteI18n "github.com/taubyte/tau-cli/i18n/website"
     7  	repositoryLib "github.com/taubyte/tau-cli/lib/repository"
     8  	websiteLib "github.com/taubyte/tau-cli/lib/website"
     9  	websitePrompts "github.com/taubyte/tau-cli/prompts/website"
    10  	websiteTable "github.com/taubyte/tau-cli/table/website"
    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 website`
    21  func New() common.Basic {
    22  	l := link{}
    23  
    24  	l.cmd = repositoryCommands.InitCommand(&repositoryCommands.LibCommands{
    25  		Type:           repositoryLib.WebsiteRepositoryType,
    26  		I18nCreated:    websiteI18n.Created,
    27  		I18nEdited:     websiteI18n.Edited,
    28  		I18nCheckedOut: websiteI18n.CheckedOut,
    29  		I18nPulled:     websiteI18n.Pulled,
    30  		I18nPushed:     websiteI18n.Pushed,
    31  		I18nRegistered: websiteI18n.Registered,
    32  
    33  		PromptsCreateThis: websitePrompts.CreateThis,
    34  		PromptsEditThis:   websitePrompts.EditThis,
    35  
    36  		PromptNew: func(ctx *cli.Context) (interface{}, repositoryCommands.Resource, error) {
    37  			iface, resource, err := websitePrompts.New(ctx)
    38  			return iface, Wrap(resource), err
    39  		},
    40  		PromptsEdit: func(ctx *cli.Context, resource repositoryCommands.Resource) (interface{}, error) {
    41  			return websitePrompts.Edit(ctx, resource.(wrapped).UnWrap())
    42  		},
    43  		PromptsGetOrSelect: func(ctx *cli.Context) (repositoryCommands.Resource, error) {
    44  			resource, err := websitePrompts.GetOrSelect(ctx)
    45  			return Wrap(resource), err
    46  		},
    47  		LibNew: func(resource repositoryCommands.Resource) error {
    48  			return websiteLib.New(resource.(wrapped).UnWrap())
    49  		},
    50  		LibSet: func(resource repositoryCommands.Resource) error {
    51  			return websiteLib.Set(resource.(wrapped).UnWrap())
    52  		},
    53  		TableConfirm: func(ctx *cli.Context, resource repositoryCommands.Resource, prompt string) bool {
    54  			return websiteTable.Confirm(ctx, resource.(wrapped).UnWrap(), prompt)
    55  		},
    56  	})
    57  
    58  	return l
    59  }