topmark.cli.state¶
Strongly typed Click invocation state for TopMark CLI commands.
TopmarkCliState
dataclass
¶
TopmarkCliState(
*,
verbosity=0,
quiet=False,
output_format=OutputFormat.TEXT,
color_mode=ColorMode.AUTO,
color_enabled=False,
console=(lambda: Console(enable_color=False))(),
log_level=None,
prune_pipeline_views=True,
apply_changes=False,
write_mode=None,
resolved_writer_options=None,
policy=MutablePolicy(),
)
Shared invocation-scoped CLI state stored on Click contexts.
This state object holds the strongly typed human-output/runtime fields that are shared across multiple CLI helpers during a single command invocation.
The extras mapping stores a small number of internal invocation-scoped
bridge values shared across CLI helpers.
bootstrap_cli_state ¶
Create or normalize the typed CLI state stored on ctx.obj.
This is the entrypoint bootstrap helper for the CLI layer. It should be
called by the root Click group and by command entrypoints instead of
ctx.ensure_object(dict).
Behavior
- If
ctx.objalready containsTopmarkCliState, return it. - If
ctx.objisNone, create a fresh default state. - If
ctx.objis a mapping, lift known typed fields intoTopmarkCliStateand preserve additional string-keyed values inextras. - Otherwise, raise
TypeError.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
Context
|
Active Click context. |
required |
Returns:
| Type | Description |
|---|---|
TopmarkCliState
|
The bootstrapped typed CLI state. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
Source code in src/topmark/cli/state.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | |
get_cli_state ¶
Return the typed CLI state stored on ctx.obj.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
Context
|
Active Click context. |
required |
Returns:
| Type | Description |
|---|---|
TopmarkCliState
|
The typed CLI state. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |