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

Function runEnable

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

Source from the content-addressed store, hash-verified

62}
63
64func runEnable(opts *EnableOptions) 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.DisabledManually, shared.DisabledInactivity}
77 workflow, err := shared.ResolveWorkflow(opts.Prompter,
78 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 disabled workflows to enable")
83 }
84 return err
85 }
86
87 path := fmt.Sprintf("repos/%s/actions/workflows/%d/enable", 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 enable workflow: %w", err)
91 }
92
93 if opts.IO.CanPrompt() {
94 cs := opts.IO.ColorScheme()
95 fmt.Fprintf(opts.IO.Out, "%s Enabled %s\n", cs.SuccessIcon(), cs.Bold(workflow.Name))
96 }
97
98 return nil
99}

Callers 2

NewCmdEnableFunction · 0.85
TestEnableRunFunction · 0.85

Calls 11

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

Tested by 1

TestEnableRunFunction · 0.68