Hi,
I'm trying to learn the flag package that implements command-line flag parsing, because its doc is not too clear to me. Here are my questions:
1. The two examples I found,
both contain a function "usage()", but there is no explicit calling of function "usage()" in the code (only a hint that it will somehow get called), nor the function "usage()" is in the flag package doc.
2. I'm trying to compare it with the traditional *nix getopt. And seems that getopt will rearrange command line arguments so that switches comes first, while the flag package will not, correct? Also, with getopt, long options may be abbreviated, as long as the abbreviation is not ambiguous. Is it true for the flag package's behavior?
Now you can see why I'm scratching my head for this simple package. Again, I'm trying to learn the flag package by example, so could you give me a short example that,
- have one mandatory switch and an optional one
- will prompt the usage when
1. no command line arguments
2. the mandatory switch is missing
- will prompt the usage when wrong switches are provided
- also throw in handling the additional non-flag arguments (via flag.Args()) please
TIA