github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/cmd/state/internal/cmdtree/protocol.go (about)

     1  package cmdtree
     2  
     3  import (
     4  	"github.com/ActiveState/cli/internal/captain"
     5  	"github.com/ActiveState/cli/internal/locale"
     6  	"github.com/ActiveState/cli/internal/primer"
     7  	"github.com/ActiveState/cli/internal/runners/protocol"
     8  )
     9  
    10  func newProtocolCommand(prime *primer.Values) *captain.Command {
    11  	runner := protocol.New(prime)
    12  	params := protocol.Params{}
    13  
    14  	cmd := captain.NewCommand(
    15  		"_protocol",
    16  		"",
    17  		locale.Tl("protocol_description", "Process URLs that use the state protocol"),
    18  		prime,
    19  		[]*captain.Flag{},
    20  		[]*captain.Argument{
    21  			{
    22  				Name:        "URL",
    23  				Description: locale.Tl("protocol_args_url", "The URL to process"),
    24  				Required:    true,
    25  				Value:       &params.URL,
    26  			},
    27  		},
    28  		func(_ *captain.Command, _ []string) error {
    29  			return runner.Run(params)
    30  		},
    31  	)
    32  	cmd.SetHidden(true)
    33  
    34  	return cmd
    35  }