github.com/taubyte/tau-cli@v0.1.13-0.20240326000942-487f0d57edfc/prompts/internal/source.go (about)

     1  package main
     2  
     3  import (
     4  	"github.com/pterm/pterm"
     5  	"github.com/taubyte/tau-cli/flags"
     6  	"github.com/taubyte/tau-cli/prompts"
     7  	"github.com/urfave/cli/v2"
     8  )
     9  
    10  var SourceCommand = &cli.Command{
    11  	Name: "source",
    12  	Flags: []cli.Flag{
    13  		flags.Source,
    14  	},
    15  	Action: func(ctx *cli.Context) error {
    16  
    17  		// New
    18  		source, err := prompts.GetOrSelectSource(ctx)
    19  		if err != nil {
    20  			return err
    21  		}
    22  
    23  		// Edit, sending empty cli context so that the flags are not set
    24  		source, err = prompts.GetOrSelectSource(&cli.Context{}, source.String())
    25  		if err != nil {
    26  			return err
    27  		}
    28  
    29  		pterm.Success.Printfln("Got source: `%s`", source)
    30  		return nil
    31  	},
    32  }