File: docopt.go

package info (click to toggle)
golang-github-anacrolix-missinggo 2.1.0-7
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 872 kB
  • sloc: makefile: 4
file content (23 lines) | stat: -rw-r--r-- 426 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package docopt

import (
	"fmt"
	"os"

	"github.com/docopt/docopt-go"
)

func Parse(doc string) (opts map[string]interface{}) {
	opts, err := docopt.Parse(doc, nil, true, "1.2.3", false, false)
	if ue, ok := err.(*docopt.UserError); ok {
		if ue.Error() != "" {
			fmt.Fprintf(os.Stderr, "\n%s\n", ue)
		}
		os.Exit(2)
	}
	if err != nil {
		fmt.Fprintf(os.Stderr, "error parsing docopt: %#v\n", err)
		os.Exit(1)
	}
	return
}