Skip to main content

FlagSet

Struct FlagSet 

Source
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

Source

pub fn new(name: &str) -> FlagSet

An empty flag set named name; output goes to stderr.

Source

pub fn name(&self) -> &str

The name of the flag set.

Source

pub fn string(&mut self, name: &str, value: &str, usage: &str) -> Flag<String>

Defines a string flag.

Source

pub fn int(&mut self, name: &str, value: i64, usage: &str) -> Flag<i64>

Defines an int flag (64 bits on every platform gadk supports).

Source

pub fn int64(&mut self, name: &str, value: i64, usage: &str) -> Flag<i64>

Defines an int64 flag.

Source

pub fn bool(&mut self, name: &str, value: bool, usage: &str) -> Flag<bool>

Defines a bool flag.

Source

pub fn duration( &mut self, name: &str, value: GoDuration, usage: &str, ) -> Flag<GoDuration>

Defines a duration flag.

Source

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.

Source

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).

Source

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.

Source

pub fn parsed(&self) -> bool

Whether FlagSet::parse has been called.

Source

pub fn args(&self) -> Vec<String>

The arguments after the flags.

Source

pub fn is_set(&self, name: &str) -> bool

Whether the flag was set on the command line.

Source

pub fn set_output(&mut self, out: Arc<Mutex<dyn Write + Send>>)

Replaces the output sink; the default is stderr.

Source

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.

Trait Implementations§

Source§

impl Debug for FlagSet

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for FlagSet

§

impl !Sync for FlagSet

§

impl !UnwindSafe for FlagSet

§

impl Forget for FlagSet

§

impl Freeze for FlagSet
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze, *const LeafNode<String, SetValZST> is !null: Freeze, PhantomData<(Owned, LeafOrInternal)>: Freeze, PhantomData<Box<(String, SetValZST)>>: Freeze, *const LeafNode<String, FlagDef> is !null: Freeze, PhantomData<Box<(String, FlagDef)>>: Freeze, PhantomData<String>: Freeze, *const ArcInner<Mutex<dyn Write + Send>> is !null: Freeze, PhantomData<ArcInner<Mutex<dyn Write + Send>>>: Freeze,

§

impl Move for FlagSet

§

impl Send for FlagSet
where RawVecInner: Send, NodeRef<Owned, String, SetValZST, LeafOrInternal>: Send, BoxRaw<(String, SetValZST)>: Send, NodeRef<Owned, String, FlagDef, LeafOrInternal>: Send, BoxRaw<(String, FlagDef)>: Send, Arc<Mutex<dyn Write + Send>>: Send,

§

impl Unpin for FlagSet
where *const u8 is !null: Unpin, *const LeafNode<String, SetValZST> is !null: Unpin, Box<(String, SetValZST)>: Unpin, *const LeafNode<String, FlagDef> is !null: Unpin, Box<(String, FlagDef)>: Unpin, Arc<Mutex<dyn Write + Send>>: Unpin,

§

impl UnsafeUnpin for FlagSet
where *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, *const LeafNode<String, SetValZST> is !null: UnsafeUnpin, PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin, PhantomData<Box<(String, SetValZST)>>: UnsafeUnpin, *const LeafNode<String, FlagDef> is !null: UnsafeUnpin, PhantomData<Box<(String, FlagDef)>>: UnsafeUnpin, PhantomData<String>: UnsafeUnpin, *const ArcInner<Mutex<dyn Write + Send>> is !null: UnsafeUnpin, PhantomData<ArcInner<Mutex<dyn Write + Send>>>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.