| 20 | } |
| 21 | |
| 22 | func 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, |