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

Function NewCmdDisable

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

Source from the content-addressed store, hash-verified

28}
29
30func NewCmdDisable(f *cmdutil.Factory, runF func(*DisableOptions) error) *cobra.Command {
31 opts := &DisableOptions{
32 IO: f.IOStreams,
33 HttpClient: f.HttpClient,
34 Prompter: f.Prompter,
35 }
36
37 cmd := &cobra.Command{
38 Use: "disable [<workflow-id> | <workflow-name>]",
39 Short: "Disable a workflow",
40 Long: "Disable a workflow, preventing it from running or showing 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 runDisable(opts)
58 },
59 }
60
61 return cmd
62}
63
64func runDisable(opts *DisableOptions) error {
65 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