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

     1  package application
     2  
     3  import (
     4  	"github.com/taubyte/tau-cli/cli/common"
     5  	applicationI18n "github.com/taubyte/tau-cli/i18n/application"
     6  	applicationLib "github.com/taubyte/tau-cli/lib/application"
     7  	applicationPrompts "github.com/taubyte/tau-cli/prompts/application"
     8  	"github.com/urfave/cli/v2"
     9  )
    10  
    11  func (link) Select() common.Command {
    12  	return common.Create(
    13  		&cli.Command{
    14  			Action: _select,
    15  		},
    16  	)
    17  }
    18  
    19  func _select(ctx *cli.Context) error {
    20  	application, deselect, err := applicationPrompts.GetSelectOrDeselect(ctx)
    21  	if err != nil {
    22  		return err
    23  	}
    24  
    25  	if deselect {
    26  		err = applicationLib.Deselect(ctx, application.Name)
    27  		if err != nil {
    28  			return err
    29  		}
    30  		applicationI18n.Deselected(application.Name)
    31  	} else {
    32  		err = applicationLib.Select(ctx, application.Name)
    33  		if err != nil {
    34  			return err
    35  		}
    36  		applicationI18n.Selected(application.Name)
    37  	}
    38  
    39  	return nil
    40  }