Struct argparse::parser::ArgumentParser[][src]

pub struct ArgumentParser<'parser> { /* fields omitted */ }

The main argument parser class


impl<'parser> ArgumentParser<'parser>

Create an empty argument parser

Borrow mutable variable for an argument

This returns Ref object which should be used configure the option

Add option to argument parser

This is only useful for options that don't store value. For example Print(...)

Set description of the command

Print help

Usually command-line option is used for printing help, this is here for any awkward cases

Print usage

Usually printed into stderr on error of command-line parsing

Parse arguments

This is most powerful method. Usually you need parse_args or parse_args_or_exit instead

Write an error similar to one produced by the library itself

Only needed if you like to do some argument validation that is out of scope of the argparse

Configure parser to ignore options when first non-option argument is encountered.

Useful for commands that want to pass following options to the subcommand or subprocess, but need some options to be set before command is specified.

Do not put double-dash (bare --) into argument

The double-dash is used to stop parsing options and treat all the following tokens as the arguments regardless of whether they start with dash (minus) or not.

The method only useful for List arguments. On by default. The method allows to set option to false so that cmd xx -- yy will get xx -- yy as arguments instead of xx yy by default. This is useful if your -- argument is meaningful. Only first double-dash is ignored by default.

Convenience method to parse arguments

On error returns error code that is supposed to be returned by an application. (i.e. zero on --help and 2 on argument error)

The simplest conveninece method

The method returns only in case of successful parsing or exits with appropriate code (including successful on --help) otherwise.

Auto Trait Implementations

impl<'parser> !Send for ArgumentParser<'parser>

impl<'parser> !Sync for ArgumentParser<'parser>