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

Function NewCmdCancel

pkg/cmd/run/cancel/cancel.go:30–64  ·  view source on GitHub ↗
(f *cmdutil.Factory, runF func(*CancelOptions) error)

Source from the content-addressed store, hash-verified

28}
29
30func NewCmdCancel(f *cmdutil.Factory, runF func(*CancelOptions) error) *cobra.Command {
31 opts := &CancelOptions{
32 IO: f.IOStreams,
33 HttpClient: f.HttpClient,
34 Prompter: f.Prompter,
35 }
36
37 cmd := &cobra.Command{
38 Use: "cancel [<run-id>]",
39 Short: "Cancel a workflow run",
40 Args: cobra.MaximumNArgs(1),
41 RunE: func(cmd *cobra.Command, args []string) error {
42 // support `-R, --repo` override
43 opts.BaseRepo = f.BaseRepo
44
45 if len(args) > 0 {
46 opts.RunID = args[0]
47 } else if !opts.IO.CanPrompt() {
48 return cmdutil.FlagErrorf("run ID required when not running interactively")
49 } else {
50 opts.Prompt = true
51 }
52
53 if runF != nil {
54 return runF(opts)
55 }
56
57 return runCancel(opts)
58 },
59 }
60
61 cmd.Flags().BoolVar(&opts.Force, "force", false, "Force cancel a workflow run")
62
63 return cmd
64}
65
66func runCancel(opts *CancelOptions) error {
67 if opts.RunID != "" {

Callers 1

TestNewCmdCancelFunction · 0.85

Calls 3

FlagErrorfFunction · 0.92
runCancelFunction · 0.85
CanPromptMethod · 0.80

Tested by 1

TestNewCmdCancelFunction · 0.68