MCPcopy
hub / github.com/cli/cli / NewCmdUnarchive

Function NewCmdUnarchive

pkg/cmd/repo/unarchive/unarchive.go:28–65  ·  view source on GitHub ↗
(f *cmdutil.Factory, runF func(*UnarchiveOptions) error)

Source from the content-addressed store, hash-verified

26}
27
28func NewCmdUnarchive(f *cmdutil.Factory, runF func(*UnarchiveOptions) error) *cobra.Command {
29 opts := &UnarchiveOptions{
30 IO: f.IOStreams,
31 HttpClient: f.HttpClient,
32 Config: f.Config,
33 BaseRepo: f.BaseRepo,
34 Prompter: f.Prompter,
35 }
36
37 cmd := &cobra.Command{
38 Use: "unarchive [<repository>]",
39 Short: "Unarchive a repository",
40 Long: heredoc.Doc(`Unarchive a GitHub repository.
41
42With no argument, unarchives the current repository.`),
43 Args: cobra.MaximumNArgs(1),
44 RunE: func(cmd *cobra.Command, args []string) error {
45 if len(args) > 0 {
46 opts.RepoArg = args[0]
47 }
48
49 if !opts.Confirmed && !opts.IO.CanPrompt() {
50 return cmdutil.FlagErrorf("--yes required when not running interactively")
51 }
52
53 if runF != nil {
54 return runF(opts)
55 }
56
57 return unarchiveRun(opts)
58 },
59 }
60
61 cmd.Flags().BoolVar(&opts.Confirmed, "confirm", false, "Skip the confirmation prompt")
62 _ = cmd.Flags().MarkDeprecated("confirm", "use `--yes` instead")
63 cmd.Flags().BoolVarP(&opts.Confirmed, "yes", "y", false, "Skip the confirmation prompt")
64 return cmd
65}
66
67func unarchiveRun(opts *UnarchiveOptions) error {
68 cs := opts.IO.ColorScheme()

Callers 1

TestNewCmdUnarchiveFunction · 0.85

Calls 3

FlagErrorfFunction · 0.92
unarchiveRunFunction · 0.85
CanPromptMethod · 0.80

Tested by 1

TestNewCmdUnarchiveFunction · 0.68