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

Function runDisable

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

Source from the content-addressed store, hash-verified

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

Callers 2

TestDisableRunFunction · 0.85
NewCmdDisableFunction · 0.85

Calls 11

NewClientFromHTTPFunction · 0.92
ResolveWorkflowFunction · 0.92
FullNameFunction · 0.92
CanPromptMethod · 0.80
ColorSchemeMethod · 0.80
SuccessIconWithColorMethod · 0.80
BoldMethod · 0.80
ErrorfMethod · 0.65
BaseRepoMethod · 0.65
RESTMethod · 0.65
RepoHostMethod · 0.65

Tested by 1

TestDisableRunFunction · 0.68