MCPcopy Index your code
hub / github.com/cli/cli / NewCmdEnable

Function NewCmdEnable

pkg/cmd/workflow/enable/enable.go:30–62  ·  view source on GitHub ↗
(f *cmdutil.Factory, runF func(*EnableOptions) error)

Source from the content-addressed store, hash-verified

28}
29
30func NewCmdEnable(f *cmdutil.Factory, runF func(*EnableOptions) error) *cobra.Command {
31 opts := &EnableOptions{
32 IO: f.IOStreams,
33 HttpClient: f.HttpClient,
34 Prompter: f.Prompter,
35 }
36
37 cmd := &cobra.Command{
38 Use: "enable [<workflow-id> | <workflow-name>]",
39 Short: "Enable a workflow",
40 Long: "Enable a workflow, allowing it to be run and show up when listing workflows.",
41 Args: cobra.MaximumNArgs(1),
42 RunE: func(cmd *cobra.Command, args []string) error {
43 // support `-R, --repo` override
44 opts.BaseRepo = f.BaseRepo
45
46 if len(args) > 0 {
47 opts.Selector = args[0]
48 } else if !opts.IO.CanPrompt() {
49 return cmdutil.FlagErrorf("workflow ID or name required when not running interactively")
50 } else {
51 opts.Prompt = true
52 }
53
54 if runF != nil {
55 return runF(opts)
56 }
57 return runEnable(opts)
58 },
59 }
60
61 return cmd
62}
63
64func runEnable(opts *EnableOptions) error {
65 c, err := opts.HttpClient()

Callers 1

TestNewCmdEnableFunction · 0.85

Calls 3

FlagErrorfFunction · 0.92
runEnableFunction · 0.85
CanPromptMethod · 0.80

Tested by 1

TestNewCmdEnableFunction · 0.68