hpcflow.sdk.cli_common.BoolOrString#
- class hpcflow.sdk.cli_common.BoolOrString(allowed_strings, true_strings=None, false_strings=None)#
Bases:
ParamType
Custom Click parameter type to accepts a bool or a choice of strings.
Methods
Convert the value to the correct type.
Helper method to fail with an invalid value message.
Returns the metavar default for this param if it provides one.
Optionally might return extra information about a missing parameter.
Return a list of
CompletionItem
objects for the incomplete value.Given a value from an environment variable this splits it up into small chunks depending on the defined envvar list splitter.
Gather information that could be useful for a tool generating user-facing documentation.
Attributes
if a list of this type is expected and the value is pulled from a string environment variable, this is what splits it up.
the descriptive name of this type
- convert(value, param, ctx)#
Convert the value to the correct type. This is not called if the value is
None
(the missing value).This must accept string values from the command line, as well as values that are already the correct type. It may also convert other compatible types.
The
param
andctx
arguments may beNone
in certain situations, such as when converting prompt input.If the value cannot be converted, call
fail()
with a descriptive message.- Parameters:
value – The value to convert.
param – The parameter that is using this type to convert its value. May be
None
.ctx – The current context that arrived at this value. May be
None
.
- envvar_list_splitter: t.ClassVar[t.Optional[str]] = None#
if a list of this type is expected and the value is pulled from a string environment variable, this is what splits it up. None means any whitespace. For all parameters the general rule is that whitespace splits them up. The exception are paths and files which are split by
os.path.pathsep
by default (“:” on Unix and “;” on Windows).
- fail(message, param=None, ctx=None)#
Helper method to fail with an invalid value message.
- get_metavar(param)#
Returns the metavar default for this param if it provides one.
- get_missing_message(param)#
Optionally might return extra information about a missing parameter.
New in version 2.0.
- shell_complete(ctx, param, incomplete)#
Return a list of
CompletionItem
objects for the incomplete value. Most types do not provide completions, but some do, and this allows custom types to provide custom completions as well.- Parameters:
- Return type:
List[CompletionItem]
New in version 8.0.
- split_envvar_value(rv)#
Given a value from an environment variable this splits it up into small chunks depending on the defined envvar list splitter.
If the splitter is set to None, which means that whitespace splits, then leading and trailing whitespace is ignored. Otherwise, leading and trailing splitters usually lead to empty items being included.