An open API service providing repository metadata for many open source software ecosystems.

Package Usage: go: rsc.io/getopt

Package getopt parses command lines using getopt(3) syntax. It is a replacement for flag.Parse but still expects flags themselves to be defined in package flag. Flags defined with one-letter names are available as short flags (invoked using one dash, as in -x) and all flags are available as long flags (invoked using two dashes, as in --x or --xylophone). To use, define flags as usual with package flag. Then introduce any aliases by calling getopt.Alias: Or call getopt.Aliases to define a list of aliases: One name in each pair must already be defined in package flag (so either "n" or "dry-run", and also either "v" or "verbose"). Then parse the command-line: If it encounters an error, Parse calls flag.Usage and then exits the program. When writing a custom flag.Usage function, call getopt.PrintDefaults instead of flag.PrintDefaults to get a usage message that includes the names of aliases in flag descriptions. At initialization time, this package installs a new flag.Usage that is the same as the default flag.Usage except that it calls getopt.PrintDefaults instead of flag.PrintDefaults. This package also defines a FlagSet wrapping the standard flag.FlagSet. In general Go flag parsing is preferred for new programs, because it is not as pedantic about the number of dashes used to invoke a flag (you can write -verbose or --verbose and the program does not care). This package is meant to be used in situations where, for legacy reasons, it is important to use exactly getopt(3) syntax, such as when rewriting in Go an existing tool that already uses getopt(3).
1 version
Latest release: almost 8 years ago
15 dependent packages

View more package details: https://packages.ecosystem.code.gouv.fr/registries/proxy.golang.org/packages/rsc.io/getopt

Dependent Repos 0