CLI¶
Public CLI exports for TexSmith.
debug_enabled ¶
debug_enabled() -> bool
Return whether full tracebacks should be displayed.
Source code in src/texsmith/ui/cli/state.py
258 259 260 261 262 263 | |
emit_error ¶
emit_error(
message: str, *, exception: BaseException | None = None
) -> None
Log an error-level message to stderr respecting verbosity settings.
Source code in src/texsmith/ui/cli/state.py
251 252 253 254 255 | |
emit_warning ¶
emit_warning(
message: str, *, exception: BaseException | None = None
) -> None
Log a warning-level message to stderr respecting verbosity settings.
Source code in src/texsmith/ui/cli/state.py
246 247 248 | |
ensure_rich_compat ¶
ensure_rich_compat() -> None
Patch Rich stub modules provided by tests to expose required attributes.
Source code in src/texsmith/ui/cli/state.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |
get_cli_state ¶
get_cli_state(
ctx: Context | Context | None = None,
*,
create: bool = True,
) -> CLIState
Return the CLI state associated with the active Typer context.
Source code in src/texsmith/ui/cli/state.py
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 | |
main ¶
main() -> None
Entry point compatible with console scripts.
Source code in src/texsmith/ui/cli/app.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
Typer application wiring for the TeXSmith CLI.
HelpOnEmptyCommand ¶
HelpOnEmptyCommand(*args: object, **kwargs: object)
Bases: TyperCommand
Typer command that disables positional argument enforcement.
Source code in src/texsmith/ui/cli/app.py
17 18 19 20 21 | |
main ¶
main() -> None
Entry point compatible with console scripts.
Source code in src/texsmith/ui/cli/app.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
Shared CLI state management utilities.
CLIState
dataclass
¶
CLIState(verbosity: int = 0, show_tracebacks: bool = False)
Shared state controlling CLI diagnostics.
consume_events ¶
consume_events(name: str) -> list[dict[str, Any]]
Retrieve and clear events for the given name.
Source code in src/texsmith/ui/cli/state.py
108 109 110 | |
record_event ¶
record_event(
name: str, payload: Mapping[str, Any] | None = None
) -> None
Store a structured diagnostic event for later presentation.
Source code in src/texsmith/ui/cli/state.py
103 104 105 106 | |
debug_enabled ¶
debug_enabled() -> bool
Return whether full tracebacks should be displayed.
Source code in src/texsmith/ui/cli/state.py
258 259 260 261 262 263 | |
emit_error ¶
emit_error(
message: str, *, exception: BaseException | None = None
) -> None
Log an error-level message to stderr respecting verbosity settings.
Source code in src/texsmith/ui/cli/state.py
251 252 253 254 255 | |
emit_warning ¶
emit_warning(
message: str, *, exception: BaseException | None = None
) -> None
Log a warning-level message to stderr respecting verbosity settings.
Source code in src/texsmith/ui/cli/state.py
246 247 248 | |
ensure_rich_compat ¶
ensure_rich_compat() -> None
Patch Rich stub modules provided by tests to expose required attributes.
Source code in src/texsmith/ui/cli/state.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |
get_cli_state ¶
get_cli_state(
ctx: Context | Context | None = None,
*,
create: bool = True,
) -> CLIState
Return the CLI state associated with the active Typer context.
Source code in src/texsmith/ui/cli/state.py
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 | |
render_message ¶
render_message(
level: str,
message: str,
*,
exception: BaseException | None = None,
) -> None
Render a formatted message to the console, including optional diagnostics.
Source code in src/texsmith/ui/cli/state.py
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 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 | |
set_cli_state ¶
set_cli_state(
*,
ctx: Context | None = None,
verbosity: int | None = None,
debug: bool | None = None,
) -> CLIState
Update the CLI state, returning the current instance.
Source code in src/texsmith/ui/cli/state.py
159 160 161 162 163 164 165 166 167 168 169 170 171 | |
Auxiliary helpers used by CLI commands.
determine_output_target ¶
determine_output_target(
template_selected: bool,
documents: list[Path],
output_option: Path | None,
) -> tuple[str, Path | None]
Infer where conversion output should be written based on CLI arguments.
Source code in src/texsmith/ui/cli/utils.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | |
looks_like_document_path ¶
looks_like_document_path(candidate: str) -> bool
Return True when the string has an extension resembling a document.
Source code in src/texsmith/ui/cli/utils.py
78 79 80 81 82 83 84 85 86 87 88 | |
normalise_selector ¶
normalise_selector(selector: str | None) -> str | None
Strip surrounding quotes and whitespace from user-provided selectors.
Source code in src/texsmith/ui/cli/utils.py
91 92 93 94 95 96 97 98 | |
organise_slot_overrides ¶
organise_slot_overrides(
values: Iterable[str] | None, documents: list[Path]
) -> tuple[
dict[Path, dict[str, str]],
dict[Path, list[SlotAssignment]],
]
Produce slot selector overrides and assignments for downstream processing.
Source code in src/texsmith/ui/cli/utils.py
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | |
parse_cli_slot_tokens ¶
parse_cli_slot_tokens(
values: Iterable[str] | None,
) -> list[tuple[str, str | None, str | None, str]]
Tokenise slot overrides into (slot, path, selector, raw) tuples.
Source code in src/texsmith/ui/cli/utils.py
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 | |
parse_slot_option ¶
parse_slot_option(
values: Iterable[str] | None,
) -> dict[str, str]
Parse CLI slot overrides declared as 'slot:Section' pairs.
Source code in src/texsmith/ui/cli/utils.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | |
resolve_slot_assignments ¶
resolve_slot_assignments(
tokens: list[tuple[str, str | None, str | None, str]],
documents: list[Path],
) -> dict[Path, list[SlotAssignment]]
Resolve parsed slot tokens against provided documents.
Source code in src/texsmith/ui/cli/utils.py
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 | |
write_output_file ¶
write_output_file(target: Path, content: str) -> None
Persist LATEX content to disk, creating parent directories as needed.
Source code in src/texsmith/ui/cli/utils.py
69 70 71 72 73 74 75 | |
Bibliography-related CLI helpers.
build_reference_panel ¶
build_reference_panel(
reference: Mapping[str, object],
) -> Panel
Create a Rich panel that visualises a single bibliography entry.
Source code in src/texsmith/ui/cli/bibliography.py
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 | |
format_bibliography_person ¶
format_bibliography_person(
person: Mapping[str, object],
) -> str
Render a bibliography person dictionary into a readable string.
Source code in src/texsmith/ui/cli/bibliography.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | |
format_person_list ¶
format_person_list(
persons: Iterable[Mapping[str, object]],
) -> str
Join a sequence of person dictionaries into a comma-separated string.
Source code in src/texsmith/ui/cli/bibliography.py
53 54 55 56 | |
print_bibliography_overview ¶
print_bibliography_overview(
collection: BibliographyCollection,
) -> None
Render a formatted summary of bibliography files, issues, and entries.
Source code in src/texsmith/ui/cli/bibliography.py
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 226 227 228 229 230 231 232 233 234 235 236 237 | |
CLI command implementations exposed via texsmith.ui.cli.
This module exists primarily to make the texsmith.ui.cli.commands package
importable for documentation tools such as mkdocstrings. It re-exports the
Typer command factories defined in the sibling modules so downstream code can
import them using dotted paths (e.g. texsmith.ui.cli.commands.render).