pub struct FlagSet { /* private fields */ }Expand description
A set of flags that reports parse failures as errors (the only mode the launcher uses).
Implementations§
Source§impl FlagSet
impl FlagSet
Sourcepub fn string(&mut self, name: &str, value: &str, usage: &str) -> Flag<String>
pub fn string(&mut self, name: &str, value: &str, usage: &str) -> Flag<String>
Defines a string flag.
Sourcepub fn int(&mut self, name: &str, value: i64, usage: &str) -> Flag<i64>
pub fn int(&mut self, name: &str, value: i64, usage: &str) -> Flag<i64>
Defines an int flag (64 bits on every platform gadk supports).
Sourcepub fn int64(&mut self, name: &str, value: i64, usage: &str) -> Flag<i64>
pub fn int64(&mut self, name: &str, value: i64, usage: &str) -> Flag<i64>
Defines an int64 flag.
Sourcepub fn bool(&mut self, name: &str, value: bool, usage: &str) -> Flag<bool>
pub fn bool(&mut self, name: &str, value: bool, usage: &str) -> Flag<bool>
Defines a bool flag.
Sourcepub fn duration(
&mut self,
name: &str,
value: GoDuration,
usage: &str,
) -> Flag<GoDuration>
pub fn duration( &mut self, name: &str, value: GoDuration, usage: &str, ) -> Flag<GoDuration>
Defines a duration flag.
Sourcepub fn func(&mut self, name: &str, usage: &str, f: FlagFunc)
pub fn func(&mut self, name: &str, usage: &str, f: FlagFunc)
Defines a func flag: f is called with the value each time the flag is seen.
Sourcepub fn bool_func(&mut self, name: &str, usage: &str, f: FlagFunc)
pub fn bool_func(&mut self, name: &str, usage: &str, f: FlagFunc)
Defines a bool-func flag: like FlagSet::func, but the flag takes no value (-name
calls f with "true"; -name=v with v).
Sourcepub fn parse(&mut self, args: &[String]) -> Result<(), FlagError>
pub fn parse(&mut self, args: &[String]) -> Result<(), FlagError>
Parses args. On failure writes the error line, then Usage of <name>: and
print_defaults() to the output sink, and returns the error; -h/-help writes the
usage and returns flag: help requested.
Sourcepub fn parsed(&self) -> bool
pub fn parsed(&self) -> bool
Whether FlagSet::parse has been called.
Sourcepub fn set_output(&mut self, out: Arc<Mutex<dyn Write + Send>>)
pub fn set_output(&mut self, out: Arc<Mutex<dyn Write + Send>>)
Replaces the output sink; the default is stderr.
Sourcepub fn print_defaults(&self) -> String
pub fn print_defaults(&self) -> String
The defaults listing as a string: one entry per flag in name order,
-name placeholder (the placeholder from a back-quoted word in the usage, else the
value type; none for a bool), the usage on the same line after a tab for a one-letter
bool flag and on the next line after four spaces and a tab otherwise, and
(default v) (string defaults quoted) when the default is not the type’s zero value.