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

Function parseExportArgs

script/ghmock/export.go:22–42  ·  view source on GitHub ↗
(args []string)

Source from the content-addressed store, hash-verified

20}
21
22func parseExportArgs(args []string) (exportOptions, error) {
23 var opts exportOptions
24 fs := flag.NewFlagSet("export", flag.ContinueOnError)
25 fs.SetOutput(io.Discard)
26 fs.BoolVar(&opts.archive, "archive", false, "write a portable tar.gz archive")
27 if err := fs.Parse(args); err != nil {
28 return exportOptions{}, usageError{err}
29 }
30 switch fs.NArg() {
31 case 0:
32 opts.path = os.Getenv("GHMOCK_EXPORT_PATH")
33 if opts.path == "" {
34 return exportOptions{}, newUsageError("missing folder to export to")
35 }
36 case 1:
37 opts.path = fs.Arg(0)
38 default:
39 return exportOptions{}, newUsageError("unexpected arguments: %s", strings.Join(fs.Args()[1:], " "))
40 }
41 return opts, nil
42}
43
44// cmdExport writes everything needed to check a result to a folder or archive: each
45// run's command, output and report, every request with the response gh got,

Callers 2

cmdExportFunction · 0.85
TestParseExportArgsFunction · 0.85

Calls 2

newUsageErrorFunction · 0.85
JoinMethod · 0.80

Tested by 1

TestParseExportArgsFunction · 0.68