macro_rules! define {
($($flag:tt)*) => { ... };
}
Expand description
Entry point for registering a flag from any source file.
Examples
Please refer to the crate level documentation for several usage examples.
Grammar
The complete input grammar is as follows.
-
Zero or more doc comments:
/// ...
. These are rendered into the generated help text. -
Optional visibility specifier like
pub
orpub(crate)
. This controls the scope of code that is allowed to see the value of this flag. By default flags have private visibility, which is the default in Rust. -
Optional short name for the flag, like
-v
, followed by a comma. -
Long name for the flag, like
--verbose
. Long name is mandatory. -
Optional value-placeholder in angle brackets, like
<FILE>
. This is cosmetic and appears in generated help text. -
Optional value type preceded by colon, like
: &str
. Type is required if there is no default value or the default value is not a Rust string or boolean or integer literal. -
Optional default value preceded by equal-sign:
= "default"
.
Invocation containing as few of the above as possible:
gflags::define! {
--minimal1: bool
}
Another way to show as few as possible. Either type or default value must be specified.
gflags::define! {
--minimal2 = "default value"
}
Showing everything at once:
gflags::define! {
/// Documentation!
pub -m, --maximal <VALUE>: u32 = path::to::DEFAULT
}