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

Function runDisable

pkg/cmd/workflow/disable/disable.go:66–104  ·  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 var fae shared.FilteredAllError
83 if errors.As(err, &fae) {
84 return errors.New("there are no enabled workflows to disable")
85 }
86 return err
87 }
88
89 path, err := safeurl.JoinPath("repos", repo.RepoOwner(), repo.RepoName(), "actions", "workflows", strconv.FormatInt(workflow.ID, 10), "disable")
90 if err != nil {
91 return err
92 }
93 err = client.REST(repo.RepoHost(), "PUT", path.String(), nil, nil)
94 if err != nil {
95 return fmt.Errorf("failed to disable workflow: %w", err)
96 }
97
98 if opts.IO.CanPrompt() {
99 cs := opts.IO.ColorScheme()
100 fmt.Fprintf(opts.IO.Out, "%s Disabled %s\n", cs.SuccessIconWithColor(cs.Red), cs.Bold(workflow.Name))
101 }
102
103 return nil
104}

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