jgdv.cli.param_spec.extra

Classes

ChoiceParam

TODO A param that must be from a choice of literals

ConstrainedParam

TODO a type of parameter which is constrained in the values it can take, beyond just type.

EntryParam

TODO a parameter that if it matches,

ImplicitParam

A Parameter that is implicit, so doesn't give a help description unless

RepeatToggleParam

TODO A repeatable toggle

RepeatableParam

TODO a repeatable key param

WildcardParam

TODO a wildcard param that matches any --{key}={val}

Module Contents

class jgdv.cli.param_spec.extra.ChoiceParam(name, choices, **kwargs)[source]

Bases: jgdv.cli.param_spec.core.LiteralParam

TODO A param that must be from a choice of literals eg: ChoiceParam([blah, bloo, blee]) : blah | bloo | blee

Parameters:

choices (list[str])

matches_head(val) <Unknown>[source]

test to see if a cli argument matches this param

Matchs {self.prefix}{self.name} if not an assignment Matches {self.prefix}{self.name}{separator} if an assignment

Return type:

bool

_choices
desc: str = 'A Choice'
class jgdv.cli.param_spec.extra.ConstrainedParam(**kwargs)[source]

Bases: jgdv.cli.param_spec.param_spec.ParamSpec

TODO a type of parameter which is constrained in the values it can take, beyond just type.

eg: {name:amount, constraints={min=0, max=10}}

Parameters:

kwargs (Any)

constraints: list[Any]
desc: str = 'A Constrained Param'
class jgdv.cli.param_spec.extra.EntryParam(*args, **kwargs)[source]

Bases: jgdv.cli.param_spec.core.LiteralParam

TODO a parameter that if it matches, returns list of more params to parse

Parameters:
  • args (Any)

  • kwargs (Any)

desc: str = 'An expandable Param'
class jgdv.cli.param_spec.extra.ImplicitParam(**kwargs)[source]

Bases: jgdv.cli.param_spec.param_spec.ParamSpec

A Parameter that is implicit, so doesn’t give a help description unless forced to

Parameters:

kwargs (Any)

help_str(*, force=False) <Unknown>[source]
Parameters:

force (bool)

Return type:

str

desc: str = 'An Implicit Parameter'
class jgdv.cli.param_spec.extra.RepeatToggleParam(*args, **kwargs)[source]

Bases: jgdv.cli.param_spec.core.ToggleParam

TODO A repeatable toggle eg: -verbose -verbose -verbose

Parameters:
  • args (Any)

  • kwargs (Any)

desc: str = 'A Repeat Toggle'
class jgdv.cli.param_spec.extra.RepeatableParam(*args, **kwargs)[source]

Bases: jgdv.cli.param_spec.core.KeyParam

TODO a repeatable key param -key val -key val2 -key val3

next_value(args) <Unknown>[source]

Get as many values as match eg: args[-test, 2, -test, 3, -test, 5, -nottest, 6] -> [2,3,5], [-nottest, 6]

Parameters:

args (list)

Return type:

tuple[str, list, int]

desc: str = 'A Repeatable Key'
type_: type
class jgdv.cli.param_spec.extra.WildcardParam(*args, **kwargs)[source]

Bases: jgdv.cli.param_spec.core.AssignParam

TODO a wildcard param that matches any –{key}={val}

Parameters:
  • args (Any)

  • kwargs (Any)

matches_head(val) <Unknown>[source]
Parameters:

val (str)

Return type:

bool

next_value(args) <Unknown>[source]

get the value for a –key=val

Parameters:

args (list)

Return type:

tuple[str, list, int]

desc: str = 'A Wildcard'