MCPcopy Create free account
hub / github.com/cli/cli / NewCmdDisable

Function NewCmdDisable

pkg/cmd/workflow/disable/disable.go:32–64  ·  view source on GitHub ↗
(f *cmdutil.Factory, runF func(*DisableOptions) error)

Source from the content-addressed store, hash-verified

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

Callers 1

TestNewCmdDisableFunction · 0.85

Calls 3

FlagErrorfFunction · 0.92
runDisableFunction · 0.85
CanPromptMethod · 0.80

Tested by 1

TestNewCmdDisableFunction · 0.68