powercli.parser

Classes returned when parsing a command.

The actual parsing logic happens in powercli.command.Command.parse_args().

Module Contents

Classes

ParsedCommand

The result of a parsed command.

ParsedArgument

A parsed argument.

ParsedFlag

A parsed flag.

ParsedPositional

A parsed positional.

ParsedVariadicPositional

A parsed variadic positional.

API

class powercli.parser.ParsedCommand

The result of a parsed command.

command: powercli.command.Command[powercli.parser.ParsedCommand.FV, powercli.parser.ParsedCommand.PV]

None

The command that got parsed.

raw_args: list[str]

None

The raw arguments passed to invoke the command.

is_present(identifier: powercli.typedefs.Identifier, /) bool

Returns True when an argument with a certain identifier has been parsed.

is_absent(identifier: powercli.typedefs.Identifier, /) bool

Returns True when an argument with a certain identifier has not been parsed.

value_of_positional(identifier: powercli.typedefs.Identifier, /) PV | str

Returns the value the positional with a certain identifier holds.

value_of_flag(identifier: powercli.typedefs.Identifier, /) collections.abc.Collection[FV | int] | None

Returns the value the flag with a certain identifier holds.

values_of_variadic_positional(/) collections.abc.Collection[PV | str] | None

Returns the values of the variadic positional if present.

subcommand(/) powercli.parser.ParsedCommand[FV, PV] | None

Returns the parsed subcommand if any.

value_of(identifier: powercli.typedefs.Identifier, /) PV | str | collections.abc.Collection[FV | int] | None

Returns the value the argument with a certain identifier holds.

class powercli.parser.ParsedArgument

A parsed argument.

arg: powercli.args.Argument

None

The argument object that has been parsed.

class powercli.parser.ParsedFlag

Bases: powercli.parser.ParsedArgument

A parsed flag.

arg: powercli.args.Flag[Any, Any, powercli.parser.ParsedFlag.T]

None

The flag that got parsed.

raw_values: list[str] | None

None

The raw values that were supplied in the command-line or in the powercli.command.Command.parse_args() method.

This may be None when the flag was not specified.

values: collections.abc.Collection[powercli.parser.ParsedFlag.T | int] | None

None

The converted parsed values.

class powercli.parser.ParsedPositional

Bases: powercli.parser.ParsedArgument

A parsed positional.

arg: powercli.args.Positional[Any, Any, powercli.parser.ParsedPositional.T]

None

The positional that got parsed.

raw_value: str | None

None

The raw value that was supplied in the command-line or in the powercli.command.Command.parse_args() method.

This may be None when the positional was not specified.

value: powercli.parser.ParsedPositional.T | str

None

The converted parsed value.

class powercli.parser.ParsedVariadicPositional

Bases: powercli.parser.ParsedArgument

A parsed variadic positional.

arg: powercli.args.VariadicPositional[Any, Any, powercli.parser.ParsedVariadicPositional.T]

None

The variadic positional that got parsed.

raw_values: list[str] | None

None

The raw values that were supplied in the command-line or in the powercli.command.Command.parse_args() method.

values: collections.abc.Collection[powercli.parser.ParsedVariadicPositional.T | str]

None

The converted parsed values.