Package Usage: go: github.com/FactomProject/go-flags
Package flags provides an extensive command line option parser.
The flags package is similar in functionality to the go built-in flag package
but provides more options and uses reflection to provide a convenient and
succinct way of specifying command line options.
The following features are supported in go-flags:
Additional features specific to Windows:
The flags package uses structs, reflection and struct field tags
to allow users to specify command line options. This results in very simple
and concise specification of your application options. For example:
This specifies one option with a short name -v and a long name --verbose.
When either -v or --verbose is found on the command line, a 'true' value
will be appended to the Verbose field. e.g. when specifying -vvv, the
resulting value of Verbose will be {[true, true, true]}.
Slice options work exactly the same as primitive type options, except that
whenever the option is encountered, a value is appended to the slice.
Map options from string to primitive type are also supported. On the command
line, you specify the value for such an option as key:value. For example
Then, the AuthorInfo map can be filled with something like
-a name:Jesse -a "surname:van den Kieboom".
Finally, for full control over the conversion between command line argument
values and options, user defined types can choose to implement the Marshaler
and Unmarshaler interfaces.
The following is a list of tags for struct fields supported by go-flags:
Either the `short:` tag or the `long:` must be specified to make the field eligible as an
option.
Option groups are a simple way to semantically separate your options. All
options in a particular group are shown together in the help under the name
of the group. Namespaces can be used to specify option long names more
precisely and emphasize the options affiliation to their group.
There are currently three ways to specify option groups.
The flags package also has basic support for commands. Commands are often
used in monolithic applications that support various commands or actions.
Take git for example, all of the add, commit, checkout, etc. are called
commands. Using commands you can easily separate multiple functions of your
application.
There are currently two ways to specify a command.
The most common, idiomatic way to implement commands is to define a global
parser instance and implement each command in a separate file. These
command files should define a go init function which calls AddCommand on
the global parser.
When parsing ends and there is an active command and that command implements
the Commander interface, then its Execute method will be run with the
remaining command line arguments.
Command structs can have options which become valid to parse after the
command has been specified on the command line. It is currently not valid
to specify options from the parent level of the command after the command
name has occurred. Thus, given a top-level option "-v" and a command "add":
go-flags has builtin support to provide bash completion of flags, commands
and argument values. To use completion, the binary which uses go-flags
can be invoked in a special environment to list completion of the current
command line argument. It should be noted that this `executes` your application,
and it is up to the user to make sure there are no negative side effects (for
example from init functions).
Setting the environment variable `GO_FLAGS_COMPLETION=1` enables completion
by replacing the argument parsing routine with the completion routine which
outputs completions for the passed arguments. The basic invocation to
complete a set of arguments is therefore:
where `completion-example` is the binary, `arg1` and `arg2` are
the current arguments, and `arg3` (the last argument) is the argument
to be completed. If the GO_FLAGS_COMPLETION is set to "verbose", then
descriptions of possible completion items will also be shown, if there
are more than 1 completion items.
To use this with bash completion, a simple file can be written which
calls the binary which supports go-flags completion:
Completion requires the parser option PassDoubleDash and is therefore enforced if the environment variable GO_FLAGS_COMPLETION is set.
Customized completion for argument values is supported by implementing
the flags.Completer interface for the argument value type. An example
of a type which does so is the flags.Filename type, an alias of string
allowing simple filename completion. A slice or array argument value
whose element type implements flags.Completer will also be completed.
1 version
Latest release: over 10 years ago
View more package details: https://packages.ecosyste.ms/registries/proxy.golang.org/packages/github.com/FactomProject/go-flags
View more repository details: http://repos.ecosyste.ms/hosts/GitHub/repositories/FactomProject%2Fgo-flags
Dependent Repos 6
FactomProject/factom-walletd
Server for the factom wallet web service apiSize: 187 KB - Last synced: about 1 month ago - Pushed: over 4 years ago

FactomProject/wallet
Core Factom wallet codeSize: 83 KB - Last synced: about 1 month ago - Pushed: over 4 years ago

accumulatenetwork/accumulate
The core implementation of the Accumulate protocolLast synced: 11 months ago

FactomProject/factom-cli
CLI to interact with factomd and factom-walletdSize: 480 KB - Last synced: about 1 month ago - Pushed: about 2 years ago

FactomProject/factomd
Factom DaemonSize: 123 MB - Last synced: about 1 month ago - Pushed: about 2 years ago

AccumulateNetwork/accumulate
MIRROR ONLY ✻ Accumulate shifts the paradigm for how blockchains manage data, tokens, and usersSize: 97.6 MB - Last synced: 7 days ago - Pushed: 7 days ago


DavidAJohnston/accumulated Fork of AccumulateNetwork/accumulate
Size: 182 KB - Last synced: about 1 year ago - Pushed: over 4 years ago

