jmcore.config_file
jmcore.config_file
Narrow TOML config access for the shell TUI.
The TUI only needs to read, set, and remove string values in named top-level tables. Keeping that surface here avoids shell parsing and preserves comments and unrelated configuration through TOMLKit.
Classes
ConfigFileError
Bases: Exception
Raised when a config file cannot be safely handled by the TUI.
Source code in jmcore/src/jmcore/config_file.py
23 24 | |
Functions:
get_config_value(path: Path, section: str, key: str) -> str | None
Return a config value as text, or None when the file or key is absent.
Boolean values are rendered as "true" / "false" so shell callers
can compare against a stable string.
Source code in jmcore/src/jmcore/config_file.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | |
main(argv: Sequence[str] | None = None) -> int
Run the TUI config helper command.
Source code in jmcore/src/jmcore/config_file.py
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 | |
remove_config_value(path: Path, section: str, key: str) -> None
Remove a scalar config value, doing nothing when the file or key is absent.
Source code in jmcore/src/jmcore/config_file.py
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | |
set_config_value(path: Path, section: str, key: str, value: str, *, as_bool: bool = False) -> None
Set a string (or boolean with as_bool) config value without rewriting
the file for a no-op.
New keys are inserted before the next chapter's banner comments so that template-generated files keep every key inside its own chapter. Keys that were previously written after such a banner are moved back on update.
The value type is stable per key: an existing string value can only be
updated with a string, an existing boolean only with as_bool. With
as_bool the value must be exactly "true" or "false" and is
written as a TOML boolean.
Source code in jmcore/src/jmcore/config_file.py
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 | |