Documentation
¶
Overview ¶
Package stringargv implements parse string cmd to argv list
Example ¶
cmd := `json -o output.json -i "input1.json input2.json" -rule-list rule.json -g` argv, err := stringargv.Parse(cmd) if err != nil { log.Fatalf("cannot parse cmd: %s", cmd) } output := flag.String("o", "default-output.json", "") input := flag.String("i", "default-input.json", "") ruleList := flag.String("rule-list", "default-rule-list.json", "") global := flag.Bool("g", false, "") // Be sure to remember to parse argv if you need // use flag.CommandLine.Parse // flag.Parse will parse the os.Argv flag.CommandLine.Parse(argv[1:]) fmt.Println(*output) fmt.Println(*input) fmt.Println(*ruleList) fmt.Println(*global)
Output: output.json input1.json input2.json rule.json true
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrUnClosedQuote = errors.New("invalid cmd string: unclosed quote")
ErrUnClosedQuote represents a invalid cmd string with unclosed quote
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.