langlauf-cli 0.6.7__tar.gz → 0.7.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. {langlauf_cli-0.6.7 → langlauf_cli-0.7.0}/PKG-INFO +4 -5
  2. {langlauf_cli-0.6.7 → langlauf_cli-0.7.0}/README.md +2 -2
  3. {langlauf_cli-0.6.7 → langlauf_cli-0.7.0}/ll_cli/settings.py +3 -0
  4. langlauf_cli-0.7.0/ll_cli/ui/completion.py +274 -0
  5. {langlauf_cli-0.6.7 → langlauf_cli-0.7.0}/pyproject.toml +2 -4
  6. langlauf_cli-0.6.7/ll_cli/ui/completion.py +0 -124
  7. {langlauf_cli-0.6.7 → langlauf_cli-0.7.0}/LICENSE +0 -0
  8. {langlauf_cli-0.6.7 → langlauf_cli-0.7.0}/ll_cli/commands/configure.py +0 -0
  9. {langlauf_cli-0.6.7 → langlauf_cli-0.7.0}/ll_cli/commands/delete.py +0 -0
  10. {langlauf_cli-0.6.7 → langlauf_cli-0.7.0}/ll_cli/commands/download.py +0 -0
  11. {langlauf_cli-0.6.7 → langlauf_cli-0.7.0}/ll_cli/commands/status.py +0 -0
  12. {langlauf_cli-0.6.7 → langlauf_cli-0.7.0}/ll_cli/commands/upload.py +0 -0
  13. {langlauf_cli-0.6.7 → langlauf_cli-0.7.0}/ll_cli/errors.py +0 -0
  14. {langlauf_cli-0.6.7 → langlauf_cli-0.7.0}/ll_cli/history.py +0 -0
  15. {langlauf_cli-0.6.7 → langlauf_cli-0.7.0}/ll_cli/jenkins/builds.py +0 -0
  16. {langlauf_cli-0.6.7 → langlauf_cli-0.7.0}/ll_cli/jenkins/client.py +0 -0
  17. {langlauf_cli-0.6.7 → langlauf_cli-0.7.0}/ll_cli/jenkins/pipelines.py +0 -0
  18. {langlauf_cli-0.6.7 → langlauf_cli-0.7.0}/ll_cli/jenkins/stage_cache.py +0 -0
  19. {langlauf_cli-0.6.7 → langlauf_cli-0.7.0}/ll_cli/main.py +0 -0
  20. {langlauf_cli-0.6.7 → langlauf_cli-0.7.0}/ll_cli/output.py +0 -0
  21. {langlauf_cli-0.6.7 → langlauf_cli-0.7.0}/ll_cli/ui/json_output.py +0 -0
  22. {langlauf_cli-0.6.7 → langlauf_cli-0.7.0}/ll_cli/ui/pickers.py +0 -0
  23. {langlauf_cli-0.6.7 → langlauf_cli-0.7.0}/ll_cli/ui/tables.py +0 -0
  24. {langlauf_cli-0.6.7 → langlauf_cli-0.7.0}/ll_cli/validation.py +0 -0
@@ -1,10 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langlauf-cli
3
- Version: 0.6.7
3
+ Version: 0.7.0
4
4
  Summary: A comprehensive multi-platform tool providing a consistent and easy-to-use interface to Langlauf's online services.
5
5
  License-File: LICENSE
6
- Author: Joseph Bienhüls
7
- Author-email: bienhuels@langlauf.io
6
+ Author: Langlauf
8
7
  Requires-Python: >=3.12,<4.0
9
8
  Classifier: Programming Language :: Python :: 3
10
9
  Classifier: Programming Language :: Python :: 3.12
@@ -47,8 +46,8 @@ Upgrade with `pipx upgrade langlauf-cli` / `uv tool upgrade langlauf-cli`.
47
46
  (this also fires on first interactive use when no credentials are
48
47
  configured yet). Re-run `ll-cli configure` any time to (re-)install it.
49
48
 
50
- Bash only for now. Completion is generated statically from the live
51
- command tree, so Tab is instant — re-run `ll-cli configure` after CLI
49
+ Bash and zsh are supported. Completion is generated statically from the
50
+ live command tree, so Tab is instant — re-run `ll-cli configure` after CLI
52
51
  changes to keep the script in sync.
53
52
 
54
53
  ## Configure
@@ -26,8 +26,8 @@ Upgrade with `pipx upgrade langlauf-cli` / `uv tool upgrade langlauf-cli`.
26
26
  (this also fires on first interactive use when no credentials are
27
27
  configured yet). Re-run `ll-cli configure` any time to (re-)install it.
28
28
 
29
- Bash only for now. Completion is generated statically from the live
30
- command tree, so Tab is instant — re-run `ll-cli configure` after CLI
29
+ Bash and zsh are supported. Completion is generated statically from the
30
+ live command tree, so Tab is instant — re-run `ll-cli configure` after CLI
31
31
  changes to keep the script in sync.
32
32
 
33
33
  ## Configure
@@ -9,6 +9,9 @@ Sources, highest precedence first:
9
9
  ~/Library/Application Support/ll-cli/config.env; Windows:
10
10
  %LOCALAPPDATA%\\ll-cli\\ll-cli\\config.env). Same KEY=value syntax as
11
11
  shell env vars and the project's .env files. Missing file is non-fatal.
12
+ Setting XDG_CONFIG_HOME overrides this directory on both Linux and macOS
13
+ (platformdirs honors it) — e.g. XDG_CONFIG_HOME=$HOME/.config gives macOS
14
+ the same ~/.config/ll-cli/config.env path Linux uses by default.
12
15
  4. file secrets directory (pydantic-settings default — unused here)
13
16
  5. defaults declared on the Settings class below
14
17
 
@@ -0,0 +1,274 @@
1
+ """Static shell-completion install for `ll-cli` (bash and zsh).
2
+
3
+ Generates a self-contained completion script from the live typer app and
4
+ writes it under the user's home (~/.bash_completions/ll-cli.sh for bash,
5
+ ~/.zsh_completions/ll-cli.zsh for zsh), then ensures the matching rc file
6
+ (~/.bashrc or ~/.zshrc) sources it. Called from `ll-cli configure` after
7
+ credentials are written.
8
+
9
+ The script knows the command tree statically so Tab presses don't have to
10
+ invoke `ll-cli` — completion is instant. It needs to be regenerated when
11
+ the CLI's flags change (re-run `ll-cli configure`).
12
+ """
13
+
14
+ import os
15
+ from pathlib import Path
16
+
17
+ import typer
18
+
19
+
20
+ def _detect_shell() -> str | None:
21
+ """Return the shell name (basename of $SHELL), or None if unset."""
22
+ shell_path = os.environ.get("SHELL", "")
23
+ if not shell_path:
24
+ return None
25
+ return Path(shell_path).name
26
+
27
+
28
+ def _shell_name_from_comm(comm: str) -> str | None:
29
+ """Map a /proc `comm` string to 'bash'/'zsh', or None if it's neither.
30
+
31
+ A login shell's comm carries a leading '-' (e.g. '-zsh'); it's stripped,
32
+ along with the trailing newline /proc adds.
33
+ """
34
+ shell_name = comm.strip().removeprefix("-")
35
+ if shell_name in ("bash", "zsh"):
36
+ return shell_name
37
+ return None
38
+
39
+
40
+ def _running_shell_from_parent_process() -> str | None:
41
+ """The invoking shell from the parent process, or None if it isn't bash/zsh.
42
+
43
+ $SHELL is the *login* shell, which is wrong when the user is in a different
44
+ interactive shell (e.g. ran `zsh` from a bash login). The parent process of
45
+ `ll-cli` is the shell that launched it, so it reflects the shell actually in
46
+ use. Reads /proc/<ppid>/comm (Linux); returns None when /proc is unavailable
47
+ (e.g. macOS) or the parent isn't a shell we support, so the caller can fall
48
+ back to $SHELL.
49
+ """
50
+ parent_pid = os.getppid()
51
+ try:
52
+ comm = Path(f"/proc/{parent_pid}/comm").read_text()
53
+ except OSError:
54
+ return None
55
+ shell_name = _shell_name_from_comm(comm)
56
+ return shell_name
57
+
58
+
59
+ def _running_shell() -> str | None:
60
+ """Return the shell `ll-cli` is actually running under.
61
+
62
+ Prefers the running shell (the parent process) over $SHELL, so a user who is
63
+ in zsh but whose login shell is bash (or vice versa) gets completion for the
64
+ shell they're actually using. Falls back to $SHELL (`_detect_shell`) when the
65
+ parent process can't be identified as a supported shell.
66
+ """
67
+ shell_from_parent = _running_shell_from_parent_process()
68
+ if shell_from_parent is not None:
69
+ return shell_from_parent
70
+ login_shell = _detect_shell()
71
+ return login_shell
72
+
73
+
74
+ def _build_static_bash_completion_script() -> str:
75
+ """Render a self-contained bash completion script for `ll-cli`.
76
+
77
+ The script knows the command tree statically (subcommands + their long-form
78
+ options), so Tab presses don't have to invoke `ll-cli` — completion is
79
+ instant. Generated from the live typer app so it stays in sync as long as
80
+ `ll-cli configure` is re-run after CLI changes.
81
+ """
82
+ # local import: ll_cli.main imports this module, so importing it at module
83
+ # load would cycle. By configure-time it's fully loaded.
84
+ import click
85
+ import typer.main
86
+
87
+ from ll_cli import main as main_module
88
+
89
+ click_app = typer.main.get_command(main_module.app)
90
+ assert isinstance(click_app, click.Group)
91
+ command_words = " ".join(click_app.commands.keys())
92
+
93
+ lines = [
94
+ "_ll_cli_completion() {",
95
+ ' local cur="${COMP_WORDS[COMP_CWORD]}"',
96
+ "",
97
+ ' if [ "$COMP_CWORD" -eq 1 ]; then',
98
+ ' if [[ "$cur" == -* ]]; then',
99
+ ' COMPREPLY=( $(compgen -W "--help --version" -- "$cur") )',
100
+ " else",
101
+ f' COMPREPLY=( $(compgen -W "{command_words}" -- "$cur") )',
102
+ " fi",
103
+ " return 0",
104
+ " fi",
105
+ "",
106
+ ' if [[ "$cur" == -* ]]; then',
107
+ ' case "${COMP_WORDS[1]}" in',
108
+ ]
109
+ for command_name, command in click_app.commands.items():
110
+ long_options: list[str] = []
111
+ for param in command.params:
112
+ long_options.extend(opt for opt in param.opts if opt.startswith("--"))
113
+ long_options.append("--help")
114
+ words = " ".join(long_options)
115
+ lines.append(f" {command_name})")
116
+ lines.append(f' COMPREPLY=( $(compgen -W "{words}" -- "$cur") )')
117
+ lines.append(" ;;")
118
+ lines.extend([
119
+ " esac",
120
+ " return 0",
121
+ " fi",
122
+ "",
123
+ " # else: leave COMPREPLY empty so bash falls back to filename completion (-o default)",
124
+ " return 0",
125
+ "}",
126
+ "",
127
+ "complete -F _ll_cli_completion -o nosort -o default ll-cli",
128
+ "",
129
+ ])
130
+ return "\n".join(lines)
131
+
132
+
133
+ def _build_static_zsh_completion_script() -> str:
134
+ """Render a self-contained zsh completion script for `ll-cli`.
135
+
136
+ The zsh sibling of `_build_static_bash_completion_script`: the command tree
137
+ (subcommands + their long-form options) is baked in, so Tab presses don't
138
+ have to invoke `ll-cli`. Generated from the live typer app so it stays in
139
+ sync as long as `ll-cli configure` is re-run after CLI changes.
140
+ """
141
+ # local import: ll_cli.main imports this module, so importing it at module
142
+ # load would cycle. By configure-time it's fully loaded.
143
+ import click
144
+ import typer.main
145
+
146
+ from ll_cli import main as main_module
147
+
148
+ click_app = typer.main.get_command(main_module.app)
149
+ assert isinstance(click_app, click.Group)
150
+ command_words = " ".join(click_app.commands.keys())
151
+
152
+ lines = [
153
+ "#compdef ll-cli",
154
+ "",
155
+ "_ll_cli_completion() {",
156
+ ' local current_word="${words[CURRENT]}"',
157
+ "",
158
+ " # CURRENT == 2 is the first argument; words[1] is `ll-cli` itself.",
159
+ " if (( CURRENT == 2 )); then",
160
+ ' if [[ "$current_word" == -* ]]; then',
161
+ " compadd -- --help --version",
162
+ " else",
163
+ f" compadd -- {command_words}",
164
+ " fi",
165
+ " return",
166
+ " fi",
167
+ "",
168
+ ' if [[ "$current_word" == -* ]]; then',
169
+ ' case "${words[2]}" in',
170
+ ]
171
+ for command_name, command in click_app.commands.items():
172
+ long_options: list[str] = []
173
+ for param in command.params:
174
+ long_options.extend(opt for opt in param.opts if opt.startswith("--"))
175
+ long_options.append("--help")
176
+ words = " ".join(long_options)
177
+ lines.append(f" {command_name})")
178
+ lines.append(f" compadd -- {words}")
179
+ lines.append(" ;;")
180
+ lines.extend([
181
+ " esac",
182
+ " return",
183
+ " fi",
184
+ "",
185
+ " # else: fall back to filename completion (matches the bash -o default).",
186
+ " _files",
187
+ "}",
188
+ "",
189
+ "# If an rc file sourced us before compinit ran, bootstrap it so compdef",
190
+ "# exists, then register the completer for `ll-cli`.",
191
+ "if ! type compdef >/dev/null 2>&1; then",
192
+ " autoload -Uz compinit && compinit",
193
+ "fi",
194
+ "compdef _ll_cli_completion ll-cli",
195
+ "",
196
+ ])
197
+ return "\n".join(lines)
198
+
199
+
200
+ def _install_static_completion(
201
+ completion_path: Path, rc_path: Path, completion_script: str
202
+ ) -> Path:
203
+ """Write a completion script and ensure the shell's rc file sources it.
204
+
205
+ Shared by the bash and zsh installers — they differ only in the script body,
206
+ the completion file path, and which rc file sources it. Idempotent: the
207
+ `source` line is added only if it isn't already present in the rc file.
208
+ """
209
+ completion_path.parent.mkdir(parents=True, exist_ok=True)
210
+ completion_path.write_text(completion_script)
211
+
212
+ source_line = f"source '{completion_path}'"
213
+ rc_content = rc_path.read_text() if rc_path.is_file() else ""
214
+ if source_line not in rc_content:
215
+ rc_content = rc_content.rstrip() + f"\n{source_line}\n"
216
+ rc_path.write_text(rc_content)
217
+ return completion_path
218
+
219
+
220
+ def _install_static_bash_completion() -> Path:
221
+ """Write the static bash completion script and ensure ~/.bashrc sources it."""
222
+ installed_path = _install_static_completion(
223
+ Path.home() / ".bash_completions" / "ll-cli.sh",
224
+ Path.home() / ".bashrc",
225
+ _build_static_bash_completion_script(),
226
+ )
227
+ return installed_path
228
+
229
+
230
+ def _install_static_zsh_completion() -> Path:
231
+ """Write the static zsh completion script and ensure ~/.zshrc sources it."""
232
+ installed_path = _install_static_completion(
233
+ Path.home() / ".zsh_completions" / "ll-cli.zsh",
234
+ Path.home() / ".zshrc",
235
+ _build_static_zsh_completion_script(),
236
+ )
237
+ return installed_path
238
+
239
+
240
+ def maybe_install_shell_completion() -> None:
241
+ """Offer to install shell completion for the detected shell.
242
+
243
+ Supports bash and zsh; any other shell gets a short note and is skipped.
244
+ Silent when no shell can be identified.
245
+ """
246
+ detected_shell = _running_shell()
247
+ if detected_shell == "bash":
248
+ install_completion = _install_static_bash_completion
249
+ elif detected_shell == "zsh":
250
+ install_completion = _install_static_zsh_completion
251
+ else:
252
+ if detected_shell:
253
+ typer.echo(
254
+ f" Skipping shell completion: only bash and zsh are supported "
255
+ f"(detected: {detected_shell}).",
256
+ err=True,
257
+ )
258
+ return
259
+ should_install = typer.confirm(
260
+ f"Install shell completion for {detected_shell}?", default=True
261
+ )
262
+ if not should_install:
263
+ return
264
+ try:
265
+ installed_path = install_completion()
266
+ except Exception as err:
267
+ typer.echo(f" Could not install completion: {err}", err=True)
268
+ return
269
+ typer.echo(f" Installed {detected_shell} completion at {installed_path}")
270
+ # A child process can't reload completion in its parent shell, so offer a
271
+ # one-liner. Source the file directly (not ~/.bashrc) — faster, no side
272
+ # effects from other rc lines.
273
+ typer.echo(f" To enable in this shell: source {installed_path}")
274
+ typer.echo(" (or open a new terminal)")
@@ -3,9 +3,7 @@ name = "langlauf-cli"
3
3
  description = "A comprehensive multi-platform tool providing a consistent and easy-to-use interface to Langlauf's online services."
4
4
  readme = "README.md"
5
5
  authors = [
6
- {name = "Joseph Bienhüls", email = "bienhuels@langlauf.io"},
7
- {name = "Dennis Herbrich", email = "herbrich@langlauf.io"},
8
- {name = "Jan Stijohann", email = "stijohann@langlauf.io"},
6
+ {name = "Langlauf"},
9
7
  ]
10
8
  dynamic = ["version", "dependencies", "classifiers", "requires-python"]
11
9
 
@@ -13,7 +11,7 @@ dynamic = ["version", "dependencies", "classifiers", "requires-python"]
13
11
  ll-cli = "ll_cli.main:app"
14
12
 
15
13
  [tool.poetry]
16
- version = "0.6.7"
14
+ version = "0.7.0"
17
15
  packages = [
18
16
  { include = "ll_cli" },
19
17
  { include = "LICENSE" },
@@ -1,124 +0,0 @@
1
- """Static bash-completion install for `ll-cli`.
2
-
3
- Generates a self-contained bash completion script from the live typer app
4
- and writes it to ~/.bash_completions/ll-cli.sh, then ensures ~/.bashrc
5
- sources it. Called from `ll-cli configure` after credentials are written.
6
-
7
- The script knows the command tree statically so Tab presses don't have to
8
- invoke `ll-cli` — completion is instant. It needs to be regenerated when
9
- the CLI's flags change (re-run `ll-cli configure`).
10
- """
11
-
12
- import os
13
- from pathlib import Path
14
-
15
- import typer
16
-
17
-
18
- def _detect_shell() -> str | None:
19
- """Return the shell name (basename of $SHELL), or None if unset."""
20
- shell_path = os.environ.get("SHELL", "")
21
- if not shell_path:
22
- return None
23
- return Path(shell_path).name
24
-
25
-
26
- def _build_static_bash_completion_script() -> str:
27
- """Render a self-contained bash completion script for `ll-cli`.
28
-
29
- The script knows the command tree statically (subcommands + their long-form
30
- options), so Tab presses don't have to invoke `ll-cli` — completion is
31
- instant. Generated from the live typer app so it stays in sync as long as
32
- `ll-cli configure` is re-run after CLI changes.
33
- """
34
- # local import: ll_cli.main imports this module, so importing it at module
35
- # load would cycle. By configure-time it's fully loaded.
36
- import click
37
- import typer.main
38
-
39
- from ll_cli import main as main_module
40
-
41
- click_app = typer.main.get_command(main_module.app)
42
- assert isinstance(click_app, click.Group)
43
- command_words = " ".join(click_app.commands.keys())
44
-
45
- lines = [
46
- "_ll_cli_completion() {",
47
- ' local cur="${COMP_WORDS[COMP_CWORD]}"',
48
- "",
49
- ' if [ "$COMP_CWORD" -eq 1 ]; then',
50
- ' if [[ "$cur" == -* ]]; then',
51
- ' COMPREPLY=( $(compgen -W "--help --version" -- "$cur") )',
52
- " else",
53
- f' COMPREPLY=( $(compgen -W "{command_words}" -- "$cur") )',
54
- " fi",
55
- " return 0",
56
- " fi",
57
- "",
58
- ' if [[ "$cur" == -* ]]; then',
59
- ' case "${COMP_WORDS[1]}" in',
60
- ]
61
- for command_name, command in click_app.commands.items():
62
- long_options: list[str] = []
63
- for param in command.params:
64
- long_options.extend(opt for opt in param.opts if opt.startswith("--"))
65
- long_options.append("--help")
66
- words = " ".join(long_options)
67
- lines.append(f" {command_name})")
68
- lines.append(f' COMPREPLY=( $(compgen -W "{words}" -- "$cur") )')
69
- lines.append(" ;;")
70
- lines.extend([
71
- " esac",
72
- " return 0",
73
- " fi",
74
- "",
75
- " # else: leave COMPREPLY empty so bash falls back to filename completion (-o default)",
76
- " return 0",
77
- "}",
78
- "",
79
- "complete -F _ll_cli_completion -o nosort -o default ll-cli",
80
- "",
81
- ])
82
- return "\n".join(lines)
83
-
84
-
85
- def _install_static_bash_completion() -> Path:
86
- """Write the static completion script and ensure ~/.bashrc sources it."""
87
- completion_path = Path.home() / ".bash_completions" / "ll-cli.sh"
88
- completion_path.parent.mkdir(parents=True, exist_ok=True)
89
- completion_path.write_text(_build_static_bash_completion_script())
90
-
91
- rc_path = Path.home() / ".bashrc"
92
- source_line = f"source '{completion_path}'"
93
- rc_content = rc_path.read_text() if rc_path.is_file() else ""
94
- if source_line not in rc_content:
95
- rc_content = rc_content.rstrip() + f"\n{source_line}\n"
96
- rc_path.write_text(rc_content)
97
- return completion_path
98
-
99
-
100
- def maybe_install_shell_completion() -> None:
101
- """Offer to install bash completion. Silently skips for other shells."""
102
- detected_shell = _detect_shell()
103
- if detected_shell != "bash":
104
- if detected_shell:
105
- typer.echo(
106
- f" Skipping shell completion: only bash is supported "
107
- f"(detected: {detected_shell}).",
108
- err=True,
109
- )
110
- return
111
- should_install = typer.confirm("Install shell completion for bash?", default=True)
112
- if not should_install:
113
- return
114
- try:
115
- installed_path = _install_static_bash_completion()
116
- except Exception as err:
117
- typer.echo(f" Could not install completion: {err}", err=True)
118
- return
119
- typer.echo(f" Installed bash completion at {installed_path}")
120
- # A child process can't reload completion in its parent shell, so offer a
121
- # one-liner. Source the file directly (not ~/.bashrc) — faster, no side
122
- # effects from other rc lines.
123
- typer.echo(f" To enable in this shell: source {installed_path}")
124
- typer.echo(" (or open a new terminal)")
File without changes