Core Classes¶
Internal Click subclasses and configuration objects. Exposed publicly for advanced use cases such as subclassing or type-checking.
PycliferOption¶
Extends click.Option with is_global and env-var binding support.
pyclifer.PycliferOption
¶
Bases: StoreInMetaMixin, Option
Custom Click Option that can be marked as global for propagation.
Source code in src/pyclifer/core/classes.py
__init__(*args, is_global=False, **kwargs)
¶
Initialize the option.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
Any
|
Positional arguments for click.Option. |
()
|
is_global
|
bool
|
If True, this option will be propagated to subcommands. |
False
|
**kwargs
|
Any
|
Keyword arguments for click.Option. |
{}
|
Source code in src/pyclifer/core/classes.py
PycliferGroup¶
Base Click group class used by app_group and group. Composes
HandleResponseMixin + GlobalOptionsMixin.
pyclifer.PycliferGroup = PycliferExtraGroup
module-attribute
¶
CustomConfigOption¶
Extends click-extra's config option with multi-location Linux config file search
(/etc/<app>/, ~/.config/<app>/, etc.).
pyclifer.CustomConfigOption
¶
Bases: StoreInMetaMixin, ConfigOption
Custom ConfigOption to add support for /etc/
This class extends the default click-extra ConfigOption to include system-wide configuration directories following Linux conventions while maintaining cross-platform compatibility.
Source code in src/pyclifer/core/classes.py
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 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | |
__init__(*args, is_global=False, **kwargs)
¶
Initialize the custom config option.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
Any
|
Positional arguments. |
()
|
is_global
|
bool
|
If True, this option will be propagated to subcommands. |
False
|
**kwargs
|
Any
|
Keyword arguments. |
{}
|
Source code in src/pyclifer/core/classes.py
get_default(ctx, call=True)
¶
Override get_default to fix rich-click help rendering.
rich-click fetches the default with call=False during help generation, which returns the raw bound method. We intercept this and force evaluation to display the actual path cleanly.
Source code in src/pyclifer/core/classes.py
default_pattern()
¶
Generate the default configuration search pattern.
Creates search patterns for configuration files, prioritizing Linux system directories when running on Linux platforms. Falls back to standard user configuration directories on other platforms.
Patterns are joined with "|" so that wcmatch's SPLIT flag (active on click-extra's ConfigOption) treats each path as a separate glob target.
Returns:
| Type | Description |
|---|---|
str
|
The pipe-separated glob pattern covering all config locations. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If no click, context is available to determine CLI name. |
Source code in src/pyclifer/core/classes.py
PycliferTimerOption¶
Internal option class powering timer=True on @app_group. Subclasses click-extra's
TimerOption to integrate with pyclifer's output format: suppresses the text echo in
json/yaml mode and injects timing fields into Response.data via returns_response.
pyclifer.core.classes.PycliferTimerOption
¶
Bases: TimerOption
TimerOption integrated with pyclifer output format.
Skips the text echo in json/yaml mode — timing data is injected directly into the Response by returns_response instead.
Source code in src/pyclifer/core/classes.py
init_timer(ctx, param, value)
¶
Register the timer and store the context for deferred format check.
Source code in src/pyclifer/core/classes.py
print_timer()
¶
Print elapsed time unless the output format is json or yaml.
Output format is read at close time so that eager option processing order does not matter — meta is fully populated by then.