Module parkour::actions[][src]

Actions are used to store the parsed command-line arguments in local variables. Actions can make sure that arguments are specified at most once.

The structs SetOnce, Set, Unset, Reset, Inc, Dec, Append, SetPositional and SetSubcommand implement the Action trait. Each struct has a different strategy of updating the local variable, and is implemented for different types. For example, Inc and Dec are only implemented for integer types, whereas Set is implemented for all types.

Usage

Make sure the Action trait is in scope, e.g.

use parkour::actions::Action;
// or
use parkour::actions::Action as _;
// or
use parkour::prelude::*;

Structs

Append

Appends the parsed value(s) to the existing ones.

Dec

Decrements the value.

Inc

Increments the value.

Reset

Reset the value to it's initial state, e.g. None. If it is already in its initial state, nothing happens.

Set

Set the parsed value. When this action is performed multiple times, only the last value is preserved.

SetOnce

Set the parsed value, ensuring that it is set at most once. When the action is performed and the value is not in its initial state (e.g. None), an error is returned.

SetPositional

Like Set, but works for positional arguments.

SetSubcommand

Like Set, but works for subcommands.

Unset

Set the value to it's initial state, e.g. None. This returns an error if the value is still in its initial state.

Traits

Action

The trait for actions. Actions are used to store the parsed command-line arguments in local variables. Actions can make sure that arguments are specified at most once.

Type Definitions

ApplyResult

The result of Action::apply