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

     1  package smartops
     2  
     3  import (
     4  	structureSpec "github.com/taubyte/go-specs/structure"
     5  	resources "github.com/taubyte/tau-cli/cli/commands/resources/common"
     6  	"github.com/taubyte/tau-cli/cli/common"
     7  	"github.com/taubyte/tau-cli/flags"
     8  	smartopsI18n "github.com/taubyte/tau-cli/i18n/smartops"
     9  	smartopsLib "github.com/taubyte/tau-cli/lib/smartops"
    10  	smartopsPrompts "github.com/taubyte/tau-cli/prompts/smartops"
    11  	smartopsTable "github.com/taubyte/tau-cli/table/smartops"
    12  	"github.com/urfave/cli/v2"
    13  )
    14  
    15  func (link) New() common.Command {
    16  	var templateURL string
    17  	return (&resources.New[*structureSpec.SmartOp]{
    18  		PromptsNew: func(ctx *cli.Context) (*structureSpec.SmartOp, error) {
    19  			smartops, _templateURL, err := smartopsPrompts.New(ctx)
    20  			templateURL = _templateURL
    21  			return smartops, err
    22  		},
    23  		TableConfirm:      smartopsTable.Confirm,
    24  		PromptsCreateThis: smartopsPrompts.CreateThis,
    25  		LibNew: func(smartops *structureSpec.SmartOp) error {
    26  			return smartopsLib.New(smartops, templateURL)
    27  		},
    28  		I18nCreated: smartopsI18n.Created,
    29  
    30  		UniqueFlags: flags.Combine(
    31  			flags.Timeout,
    32  			flags.Memory,
    33  			flags.MemoryUnit,
    34  			flags.Source,
    35  			flags.Call,
    36  			flags.Template,
    37  			flags.Language,
    38  			flags.UseCodeTemplate,
    39  		),
    40  	}).Default()
    41  }