github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/cmd/state/internal/cmdtree/shell.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/shell" 8 "github.com/ActiveState/cli/pkg/project" 9 ) 10 11 const shellCmdName = "shell" 12 13 func newShellCommand(prime *primer.Values) *captain.Command { 14 runner := shell.New(prime) 15 16 params := &shell.Params{ 17 Namespace: &project.Namespaced{AllowOmitOwner: true}, 18 } 19 20 cmd := captain.NewCommand( 21 shellCmdName, 22 "", 23 locale.Tl("shell_description", "Starts a shell/prompt in a virtual environment for the given project runtime"), 24 prime, 25 []*captain.Flag{ 26 { 27 Name: "cd", 28 Shorthand: "", 29 Description: locale.Tl("flag_state_shell_cd_description", "Change to the project directory after starting virtual environment shell/prompt"), 30 Value: ¶ms.ChangeDirectory, 31 }, 32 }, 33 []*captain.Argument{ 34 { 35 Name: locale.T("arg_state_activate_namespace"), 36 Description: locale.T("arg_state_shell_namespace_description"), 37 Value: params.Namespace, 38 }, 39 }, 40 func(_ *captain.Command, _ []string) error { 41 return runner.Run(params) 42 }, 43 ) 44 cmd.SetGroup(EnvironmentUsageGroup) 45 cmd.SetAliases("prompt") 46 return cmd 47 }