Types
clo.types
General types
clo.types.Logic
module-attribute
Logic = Literal['&', '|', '!']
Logical operators used with Domains:
&: A logicalANDto place before two or more domains (arity 2).|: A logicalOR, placed before two or more domains (arity 2).!: A logicalORto place before a signle domain (arity 1).
clo.types.Env
Bases: Enum
A collection of possible environment variables. All members in this
Enum assume the following:
- The
.namerepresents the variable (prefix withCLO_) one would export in their shell. - The
.valuerepresents the long-flag (prefix with--) one would specify in their command.
clo.types.Env.CONF
class-attribute
instance-attribute
CONF = '.clorc'
NOTE: This is a special member and is not recognized as an environment variable or a flag.
The default environment file. clo will fallback to any vairables declared
in this file, barring they're explicitly set from the command-line. Empty
declarations are ignored.
clo.types.Env.INSTANCE
class-attribute
instance-attribute
INSTANCE = 'instance'
The application database to perform operations on. Equivalent to --database.
clo.types.Env.DATABASE
class-attribute
instance-attribute
DATABASE = 'database'
The application database to perform operations on. Equivalent to --database.
clo.types.Env.USERNAME
class-attribute
instance-attribute
USERNAME = 'username'
The user to perform operations as. Equivalent to --user.
clo.types.Env.PASSWORD
class-attribute
instance-attribute
PASSWORD = 'password'
The user's password. There is no command-line equivalent.
clo.types.Env.OUT
class-attribute
instance-attribute
OUT = 'out'
Where to stream the output. Equivalent to --out.
clo.types.Env.LOG
class-attribute
instance-attribute
LOG = 'log'
The level of logs to produce. Equivalent to --log.
clo.types.Env.get
get(__default=None)
Retrieve the environment variable value of a member.
| PARAMETER | DESCRIPTION |
|---|---|
__default |
A value to use if none is found in the environment.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The environment variable value
TYPE:
|
clo.types.Env.at
classmethod
at(value)
Retrieve the member who holds the specified member value.
| PARAMETER | DESCRIPTION |
|---|---|
value |
The member value to match.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Env
|
Env | None: The matching member, if found. |
clo.types.Domain
Bases: NamedTuple
Criterion to filter the search by.
clo.types.Domain.field
instance-attribute
field
The name of the field to match.
clo.types.Domain.operator
instance-attribute
operator
A comparison operator.
clo.types.Domain.value
instance-attribute
value
The value to compare.
clo.types.Secret
Secret(seq)
Bases: UserString
A string to hold secret values, but obsfucates when printed.
clo.types.AskProperty
AskProperty(prompt=None, env=None, default='', *, secret=False)
A decorator which provides a property that offers multiple methods to acquire an attribute.
In the event none is explicitly set at the time of retrieval:
- Via an optional environment vairable, or
- Promopting input from the user.
| PARAMETER | DESCRIPTION |
|---|---|
prompt |
The prompt to use when asking a use ofr input. If none is given, a generic prompt is generated.
TYPE:
|
env |
An environment variable to lookup before prompting.
TYPE:
|
default |
A value to default to if all attempts fail.
TYPE:
|
secret |
If
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
AskProperty
|
A property object. |