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

Function runDisable

pkg/cmd/workflow/disable/disable.go:66–103  ·  view source on GitHub ↗
(opts *DisableOptions)

Source from the content-addressed store, hash-verified

64}
65
66func runDisable(opts *DisableOptions) error {
67 c, err := opts.HttpClient()
68 if err != nil {
69 return fmt.Errorf("could not build http client: %w", err)
70 }
71 client := api.NewClientFromHTTP(c)
72
73 repo, err := opts.BaseRepo()
74 if err != nil {
75 return err
76 }
77
78 states := []shared.WorkflowState{shared.Active}
79 workflow, err := shared.ResolveWorkflow(
80 opts.Prompter, opts.IO, client, repo, opts.Prompt, opts.Selector, states)
81 if err != nil {
82 if _, ok := errors.AsType[shared.FilteredAllError](err); ok {
83 return errors.New("there are no enabled workflows to disable")
84 }
85 return err
86 }
87
88 path, err := safeurl.JoinPath("repos", repo.RepoOwner(), repo.RepoName(), "actions", "workflows", strconv.FormatInt(workflow.ID, 10), "disable")
89 if err != nil {
90 return err
91 }
92 err = client.REST(repo.RepoHost(), "PUT", path.String(), nil, nil)
93 if err != nil {
94 return fmt.Errorf("failed to disable workflow: %w", err)
95 }
96
97 if opts.IO.CanPrompt() {
98 cs := opts.IO.ColorScheme()
99 fmt.Fprintf(opts.IO.Out, "%s Disabled %s\n", cs.SuccessIconWithColor(cs.Red), cs.Bold(workflow.Name))
100 }
101
102 return nil
103}

Callers 2

TestDisableRunFunction · 0.85
NewCmdDisableFunction · 0.85

Calls 14

NewClientFromHTTPFunction · 0.92
ResolveWorkflowFunction · 0.92
JoinPathFunction · 0.92
CanPromptMethod · 0.80
ColorSchemeMethod · 0.80
SuccessIconWithColorMethod · 0.80
BoldMethod · 0.80
ErrorfMethod · 0.65
BaseRepoMethod · 0.65
RepoOwnerMethod · 0.65
RepoNameMethod · 0.65
RESTMethod · 0.65

Tested by 1

TestDisableRunFunction · 0.68