github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/cmd/state/internal/cmdtree/revert.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/revert"
     8  )
     9  
    10  func newRevertCommand(prime *primer.Values, globals *globalOptions) *captain.Command {
    11  	runner := revert.New(prime)
    12  	params := &revert.Params{}
    13  
    14  	return captain.NewCommand(
    15  		"revert",
    16  		locale.Tl("revert_title", "Reverting Commit"),
    17  		locale.Tl("revert_description", "Revert a commit"),
    18  		prime,
    19  		[]*captain.Flag{
    20  			{
    21  				Name:        "to",
    22  				Description: locale.Tl("revert_arg_to", "Create a new commit that brings the runtime back to the same state as the commit given"),
    23  				Value:       &params.To,
    24  			},
    25  		},
    26  		[]*captain.Argument{
    27  			{
    28  				Name:        "commit-id",
    29  				Description: locale.Tl("revert_arg_commit_id", "The commit ID to revert changes from, or HEAD for the latest commit"),
    30  				Required:    true,
    31  				Value:       &params.CommitID,
    32  			},
    33  		},
    34  		func(ccmd *captain.Command, args []string) error {
    35  			params.Force = globals.NonInteractive
    36  			return runner.Run(params)
    37  		},
    38  	).SetGroup(VCSGroup).SetSupportsStructuredOutput()
    39  }