langlauf-cli 0.7.0__tar.gz → 0.8.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 (23) hide show
  1. {langlauf_cli-0.7.0 → langlauf_cli-0.8.0}/PKG-INFO +5 -4
  2. {langlauf_cli-0.7.0 → langlauf_cli-0.8.0}/README.md +4 -3
  3. {langlauf_cli-0.7.0 → langlauf_cli-0.8.0}/ll_cli/commands/download.py +54 -2
  4. {langlauf_cli-0.7.0 → langlauf_cli-0.8.0}/ll_cli/ui/completion.py +178 -9
  5. {langlauf_cli-0.7.0 → langlauf_cli-0.8.0}/pyproject.toml +18 -9
  6. {langlauf_cli-0.7.0 → langlauf_cli-0.8.0}/LICENSE +0 -0
  7. {langlauf_cli-0.7.0 → langlauf_cli-0.8.0}/ll_cli/commands/configure.py +0 -0
  8. {langlauf_cli-0.7.0 → langlauf_cli-0.8.0}/ll_cli/commands/delete.py +0 -0
  9. {langlauf_cli-0.7.0 → langlauf_cli-0.8.0}/ll_cli/commands/status.py +0 -0
  10. {langlauf_cli-0.7.0 → langlauf_cli-0.8.0}/ll_cli/commands/upload.py +0 -0
  11. {langlauf_cli-0.7.0 → langlauf_cli-0.8.0}/ll_cli/errors.py +0 -0
  12. {langlauf_cli-0.7.0 → langlauf_cli-0.8.0}/ll_cli/history.py +0 -0
  13. {langlauf_cli-0.7.0 → langlauf_cli-0.8.0}/ll_cli/jenkins/builds.py +0 -0
  14. {langlauf_cli-0.7.0 → langlauf_cli-0.8.0}/ll_cli/jenkins/client.py +0 -0
  15. {langlauf_cli-0.7.0 → langlauf_cli-0.8.0}/ll_cli/jenkins/pipelines.py +0 -0
  16. {langlauf_cli-0.7.0 → langlauf_cli-0.8.0}/ll_cli/jenkins/stage_cache.py +0 -0
  17. {langlauf_cli-0.7.0 → langlauf_cli-0.8.0}/ll_cli/main.py +0 -0
  18. {langlauf_cli-0.7.0 → langlauf_cli-0.8.0}/ll_cli/output.py +0 -0
  19. {langlauf_cli-0.7.0 → langlauf_cli-0.8.0}/ll_cli/settings.py +0 -0
  20. {langlauf_cli-0.7.0 → langlauf_cli-0.8.0}/ll_cli/ui/json_output.py +0 -0
  21. {langlauf_cli-0.7.0 → langlauf_cli-0.8.0}/ll_cli/ui/pickers.py +0 -0
  22. {langlauf_cli-0.7.0 → langlauf_cli-0.8.0}/ll_cli/ui/tables.py +0 -0
  23. {langlauf_cli-0.7.0 → langlauf_cli-0.8.0}/ll_cli/validation.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langlauf-cli
3
- Version: 0.7.0
3
+ Version: 0.8.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
6
  Author: Langlauf
@@ -46,9 +46,10 @@ Upgrade with `pipx upgrade langlauf-cli` / `uv tool upgrade langlauf-cli`.
46
46
  (this also fires on first interactive use when no credentials are
47
47
  configured yet). Re-run `ll-cli configure` any time to (re-)install it.
48
48
 
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
51
- changes to keep the script in sync.
49
+ Bash, zsh, fish, and PowerShell are supported; `ll-cli configure` installs
50
+ completion for the shell you're currently running in. Completion is generated
51
+ statically from the live command tree, so Tab is instant — re-run `ll-cli
52
+ configure` after CLI changes to keep the script in sync.
52
53
 
53
54
  ## Configure
54
55
 
@@ -26,9 +26,10 @@ 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 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
- changes to keep the script in sync.
29
+ Bash, zsh, fish, and PowerShell are supported; `ll-cli configure` installs
30
+ completion for the shell you're currently running in. Completion is generated
31
+ statically from the live command tree, so Tab is instant — re-run `ll-cli
32
+ configure` after CLI changes to keep the script in sync.
32
33
 
33
34
  ## Configure
34
35
 
@@ -20,7 +20,7 @@ import time
20
20
 
21
21
  import rich.console
22
22
  import typer
23
- from typing import Annotated
23
+ from typing import Annotated, Literal
24
24
 
25
25
  from ll_cli import output
26
26
  from ll_cli.jenkins import builds
@@ -94,6 +94,28 @@ def _pick_build_by_version_match(
94
94
  )
95
95
 
96
96
 
97
+ def _classify_download_eligibility(
98
+ build_result: str | None,
99
+ fail_on_unstable: bool,
100
+ ) -> Literal["proceed", "warn_unstable", "refuse_unstable", "refuse_not_successful"]:
101
+ """Decide whether a finished run's result permits download, and how.
102
+
103
+ Split out from `download` as pure policy so it's unit-testable without a
104
+ live Jenkins (the gate runs after `ensure_connection`, and we don't mock).
105
+ UNSTABLE means a module stage (e.g. Symbols) failed soft but the SBOM / VDR /
106
+ report were still written and uploaded to D-Track — downloadable by default
107
+ (with a warning), unless --fail-on-unstable opts out. SUCCESS proceeds
108
+ silently; anything else (FAILURE / ABORTED / NOT_BUILT / None) is refused.
109
+ """
110
+ if build_result == "SUCCESS":
111
+ return "proceed"
112
+ if build_result == "UNSTABLE":
113
+ if fail_on_unstable:
114
+ return "refuse_unstable"
115
+ return "warn_unstable"
116
+ return "refuse_not_successful"
117
+
118
+
97
119
  def download(
98
120
  analysis_number: Annotated[
99
121
  int | None,
@@ -166,6 +188,16 @@ def download(
166
188
  "three to download all of them (the default).",
167
189
  ),
168
190
  ] = False,
191
+ fail_on_unstable: Annotated[
192
+ bool,
193
+ typer.Option(
194
+ "--fail-on-unstable",
195
+ help="Refuse to download from an UNSTABLE analysis run. By default "
196
+ "an UNSTABLE run (a build stage failed soft, but the SBOM, VDR, and "
197
+ "report were still produced) is downloaded with a warning; pass this "
198
+ "flag to abort on UNSTABLE instead.",
199
+ ),
200
+ ] = False,
169
201
  non_interactive: output.NonInteractiveOption = False,
170
202
  ) -> None:
171
203
  """Download the generated CycloneDX SBOM and vulnerability report for one analysis run.
@@ -188,6 +220,11 @@ def download(
188
220
  By default all three artifacts are saved (the CycloneDX SBOM, the
189
221
  vulnerability report PDF, and the VDR). Pass any of --cdx / --report /
190
222
  --vdr to restrict the download to just those kinds.
223
+
224
+ An UNSTABLE analysis run (a build stage failed soft, but the SBOM,
225
+ VDR, and report were still produced and uploaded) is downloaded by
226
+ default, with a warning. Pass --fail-on-unstable to refuse those
227
+ instead.
191
228
  """
192
229
  # --non-interactive forces the non-TTY path for the prompts below.
193
230
  output.set_non_interactive(non_interactive)
@@ -267,12 +304,27 @@ def download(
267
304
  f"{build.full_display_name}: RUNNING ({elapsed_seconds}s elapsed)"
268
305
  )
269
306
 
270
- if build.result != "SUCCESS":
307
+ download_eligibility = _classify_download_eligibility(build.result, fail_on_unstable)
308
+ if download_eligibility == "refuse_unstable":
309
+ typer.echo(
310
+ f"ERROR: Analysis run is UNSTABLE and --fail-on-unstable was given, "
311
+ f"refusing to download: {build.full_display_name} - {build.url}",
312
+ err=True,
313
+ )
314
+ raise typer.Abort()
315
+ if download_eligibility == "refuse_not_successful":
271
316
  typer.echo(
272
317
  f"ERROR: Cannot download artifacts, generation not successful: {build.full_display_name} - {build.url}",
273
318
  err=True,
274
319
  )
275
320
  raise typer.Abort()
321
+ if download_eligibility == "warn_unstable":
322
+ typer.echo(
323
+ f"WARNING: Analysis run is UNSTABLE — a build stage failed soft. "
324
+ f"Downloading anyway; some artifacts may be missing or incomplete: "
325
+ f"{build.full_display_name} - {build.url}",
326
+ err=True,
327
+ )
276
328
 
277
329
  try:
278
330
  outdir = outdir.resolve(strict=False)
@@ -26,19 +26,20 @@ def _detect_shell() -> str | None:
26
26
 
27
27
 
28
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.
29
+ """Map a /proc `comm` string to a supported shell name, or None.
30
30
 
31
- A login shell's comm carries a leading '-' (e.g. '-zsh'); it's stripped,
32
- along with the trailing newline /proc adds.
31
+ Recognizes bash, zsh, fish, and PowerShell (comm 'pwsh'). A login shell's
32
+ comm carries a leading '-' (e.g. '-zsh'); it's stripped, along with the
33
+ trailing newline /proc adds.
33
34
  """
34
35
  shell_name = comm.strip().removeprefix("-")
35
- if shell_name in ("bash", "zsh"):
36
+ if shell_name in ("bash", "zsh", "fish", "pwsh"):
36
37
  return shell_name
37
38
  return None
38
39
 
39
40
 
40
41
  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
+ """The invoking shell from the parent process, or None if it isn't supported.
42
43
 
43
44
  $SHELL is the *login* shell, which is wrong when the user is in a different
44
45
  interactive shell (e.g. ran `zsh` from a bash login). The parent process of
@@ -197,6 +198,126 @@ def _build_static_zsh_completion_script() -> str:
197
198
  return "\n".join(lines)
198
199
 
199
200
 
201
+ def _build_static_fish_completion_script() -> str:
202
+ """Render a self-contained fish completion script for `ll-cli`.
203
+
204
+ Fish autoloads this from its completions dir, so — unlike the bash/zsh
205
+ scripts — it's a list of `complete` directives, not a sourced function. The
206
+ command tree is baked in (subcommands gated by `__fish_use_subcommand`,
207
+ per-command options by `__fish_seen_subcommand_from`), generated from the
208
+ live typer app so it stays in sync as long as `ll-cli configure` is re-run
209
+ after CLI changes.
210
+ """
211
+ # local import: ll_cli.main imports this module, so importing it at module
212
+ # load would cycle. By configure-time it's fully loaded.
213
+ import click
214
+ import typer.main
215
+
216
+ from ll_cli import main as main_module
217
+
218
+ click_app = typer.main.get_command(main_module.app)
219
+ assert isinstance(click_app, click.Group)
220
+
221
+ lines = [
222
+ "# Static fish completion for `ll-cli`, generated from the command tree.",
223
+ "# Regenerate with `ll-cli configure` after the CLI's flags change.",
224
+ "",
225
+ "# Subcommands — offered only before a subcommand is typed (-f: no files).",
226
+ ]
227
+ for command_name in click_app.commands:
228
+ lines.append(f"complete -c ll-cli -f -n __fish_use_subcommand -a {command_name}")
229
+ lines.extend([
230
+ "",
231
+ "# Top-level options.",
232
+ "complete -c ll-cli -f -n __fish_use_subcommand -l help",
233
+ "complete -c ll-cli -f -n __fish_use_subcommand -l version",
234
+ "",
235
+ "# Per-subcommand options — offered once the subcommand is on the line.",
236
+ ])
237
+ for command_name, command in click_app.commands.items():
238
+ long_options: list[str] = []
239
+ for param in command.params:
240
+ long_options.extend(opt for opt in param.opts if opt.startswith("--"))
241
+ long_options.append("--help")
242
+ for option in long_options:
243
+ option_name = option.removeprefix("--")
244
+ condition = f"__fish_seen_subcommand_from {command_name}"
245
+ lines.append(f"complete -c ll-cli -n '{condition}' -l {option_name}")
246
+ lines.append("")
247
+ return "\n".join(lines)
248
+
249
+
250
+ def _build_static_powershell_completion_script() -> str:
251
+ """Render a PowerShell `Register-ArgumentCompleter` script for `ll-cli`.
252
+
253
+ NOT exercised by CI — PowerShell isn't in the test environment, so this is
254
+ generated from the command tree and syntax-reviewed but not run; verify it on
255
+ a machine with `pwsh`. The completer mirrors the bash/zsh logic: subcommands
256
+ at the first position, a subcommand's long options when the current word
257
+ starts with '-', and filename completion otherwise.
258
+ """
259
+ # local import: ll_cli.main imports this module, so importing it at module
260
+ # load would cycle. By configure-time it's fully loaded.
261
+ import click
262
+ import typer.main
263
+
264
+ from ll_cli import main as main_module
265
+
266
+ click_app = typer.main.get_command(main_module.app)
267
+ assert isinstance(click_app, click.Group)
268
+ subcommand_list = ", ".join(f"'{name}'" for name in click_app.commands)
269
+
270
+ lines = [
271
+ "# Static PowerShell completion for `ll-cli`, generated from the command tree.",
272
+ "# Regenerate with `ll-cli configure` after the CLI's flags change.",
273
+ "Register-ArgumentCompleter -Native -CommandName ll-cli -ScriptBlock {",
274
+ " param($wordToComplete, $commandAst, $cursorPosition)",
275
+ "",
276
+ " $elements = $commandAst.CommandElements",
277
+ " # The established subcommand is the first non-option token after",
278
+ " # `ll-cli`, ignoring the word currently being typed.",
279
+ " $subcommand = $null",
280
+ " for ($i = 1; $i -lt $elements.Count; $i++) {",
281
+ " $text = $elements[$i].Extent.Text",
282
+ " if ($i -eq $elements.Count - 1 -and $text -eq $wordToComplete) { continue }",
283
+ " if (-not $text.StartsWith('-')) { $subcommand = $text; break }",
284
+ " }",
285
+ "",
286
+ " $candidates = @()",
287
+ " if ($null -eq $subcommand) {",
288
+ " if ($wordToComplete.StartsWith('-')) {",
289
+ " $candidates = @('--help', '--version')",
290
+ " } else {",
291
+ f" $candidates = @({subcommand_list})",
292
+ " }",
293
+ " } elseif ($wordToComplete.StartsWith('-')) {",
294
+ " switch ($subcommand) {",
295
+ ]
296
+ for command_name, command in click_app.commands.items():
297
+ long_options: list[str] = []
298
+ for param in command.params:
299
+ long_options.extend(opt for opt in param.opts if opt.startswith("--"))
300
+ long_options.append("--help")
301
+ options_list = ", ".join(f"'{opt}'" for opt in long_options)
302
+ lines.append(f" '{command_name}' {{ $candidates = @({options_list}) }}")
303
+ lines.extend([
304
+ " }",
305
+ " } else {",
306
+ " # Positional argument — fall back to filename completion.",
307
+ " return [System.Management.Automation.CompletionCompleters]::CompleteFilename($wordToComplete)",
308
+ " }",
309
+ "",
310
+ ' $candidates |',
311
+ ' Where-Object { $_ -like "$wordToComplete*" } |',
312
+ " ForEach-Object {",
313
+ " [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)",
314
+ " }",
315
+ "}",
316
+ "",
317
+ ])
318
+ return "\n".join(lines)
319
+
320
+
200
321
  def _install_static_completion(
201
322
  completion_path: Path, rc_path: Path, completion_script: str
202
323
  ) -> Path:
@@ -237,22 +358,62 @@ def _install_static_zsh_completion() -> Path:
237
358
  return installed_path
238
359
 
239
360
 
361
+ def _install_static_fish_completion() -> Path:
362
+ """Write the fish completion into fish's autoload dir; no rc edit needed.
363
+
364
+ Fish autoloads completions from $XDG_CONFIG_HOME/fish/completions (or
365
+ ~/.config/fish/completions on every platform, macOS included), so — unlike
366
+ bash/zsh — there's no rc file to source it from; dropping the file in place
367
+ is enough. Idempotent: each run just rewrites the same file.
368
+ """
369
+ config_home = os.environ.get("XDG_CONFIG_HOME") or str(Path.home() / ".config")
370
+ completion_path = Path(config_home) / "fish" / "completions" / "ll-cli.fish"
371
+ completion_path.parent.mkdir(parents=True, exist_ok=True)
372
+ completion_path.write_text(_build_static_fish_completion_script())
373
+ return completion_path
374
+
375
+
376
+ def _install_static_powershell_completion() -> Path:
377
+ """Write the PowerShell completer and ensure the profile dot-sources it.
378
+
379
+ On Unix, pwsh's per-user profile is ~/.config/powershell (it does not honor
380
+ $XDG_CONFIG_HOME), so the script and the profile both live there. Idempotent:
381
+ the dot-source line is added only if it isn't already in the profile.
382
+ """
383
+ powershell_dir = Path.home() / ".config" / "powershell"
384
+ completion_path = powershell_dir / "completions" / "ll-cli.ps1"
385
+ profile_path = powershell_dir / "Microsoft.PowerShell_profile.ps1"
386
+ completion_path.parent.mkdir(parents=True, exist_ok=True)
387
+ completion_path.write_text(_build_static_powershell_completion_script())
388
+
389
+ dot_source_line = f". '{completion_path}'"
390
+ profile_content = profile_path.read_text() if profile_path.is_file() else ""
391
+ if dot_source_line not in profile_content:
392
+ profile_content = profile_content.rstrip() + f"\n{dot_source_line}\n"
393
+ profile_path.write_text(profile_content)
394
+ return completion_path
395
+
396
+
240
397
  def maybe_install_shell_completion() -> None:
241
398
  """Offer to install shell completion for the detected shell.
242
399
 
243
- Supports bash and zsh; any other shell gets a short note and is skipped.
244
- Silent when no shell can be identified.
400
+ Supports bash, zsh, fish, and PowerShell; any other shell gets a short note
401
+ and is skipped. Silent when no shell can be identified.
245
402
  """
246
403
  detected_shell = _running_shell()
247
404
  if detected_shell == "bash":
248
405
  install_completion = _install_static_bash_completion
249
406
  elif detected_shell == "zsh":
250
407
  install_completion = _install_static_zsh_completion
408
+ elif detected_shell == "fish":
409
+ install_completion = _install_static_fish_completion
410
+ elif detected_shell == "pwsh":
411
+ install_completion = _install_static_powershell_completion
251
412
  else:
252
413
  if detected_shell:
253
414
  typer.echo(
254
- f" Skipping shell completion: only bash and zsh are supported "
255
- f"(detected: {detected_shell}).",
415
+ f" Skipping shell completion: only bash, zsh, fish, and "
416
+ f"PowerShell are supported (detected: {detected_shell}).",
256
417
  err=True,
257
418
  )
258
419
  return
@@ -267,6 +428,14 @@ def maybe_install_shell_completion() -> None:
267
428
  typer.echo(f" Could not install completion: {err}", err=True)
268
429
  return
269
430
  typer.echo(f" Installed {detected_shell} completion at {installed_path}")
431
+ if detected_shell == "fish":
432
+ # Fish autoloads from its completions dir — nothing to source.
433
+ typer.echo(" Fish will autoload it; open a new shell (or run: exec fish).")
434
+ return
435
+ if detected_shell == "pwsh":
436
+ # The pwsh profile dot-sources it; reload the profile or restart pwsh.
437
+ typer.echo(" Restart PowerShell (or run: . $PROFILE) to enable it.")
438
+ return
270
439
  # A child process can't reload completion in its parent shell, so offer a
271
440
  # one-liner. Source the file directly (not ~/.bashrc) — faster, no side
272
441
  # effects from other rc lines.
@@ -11,7 +11,7 @@ dynamic = ["version", "dependencies", "classifiers", "requires-python"]
11
11
  ll-cli = "ll_cli.main:app"
12
12
 
13
13
  [tool.poetry]
14
- version = "0.7.0"
14
+ version = "0.8.0"
15
15
  packages = [
16
16
  { include = "ll_cli" },
17
17
  { include = "LICENSE" },
@@ -79,13 +79,6 @@ name = "langlauf"
79
79
  url = "https://pypi.langlauf.tech/root/stage/+simple/"
80
80
  priority = "primary"
81
81
 
82
- [tool.taskipy.settings]
83
- use_vars = true
84
-
85
- [tool.taskipy.variables]
86
- MODULE_NAME = "ll_cli"
87
- VERSION = "$(poetry version --short)"
88
-
89
82
  [tool.taskipy.tasks]
90
83
 
91
84
  # Quoting: '''...''' — multi-step script; extra args are NOT forwarded
@@ -134,13 +127,29 @@ e2e_tests = '''
134
127
  . ./.env.dev
135
128
  set +a
136
129
 
130
+ # Pin the Jenkins compose's host socket to the rootless podman socket so the
131
+ # pipeline's `docker {}` agents use podman on any machine — the compose default
132
+ # (/var/run/docker.sock) is a real Docker daemon wherever Docker is installed,
133
+ # while everything else here is rootless podman. Override via LL_PODMAN_SOCKET.
134
+ if [ -z "${LL_PODMAN_SOCKET:-}" ]; then
135
+ if [ "$(podman info --format '{{.Host.RemoteSocket.Exists}}')" != "true" ]; then
136
+ echo "Error: podman's API socket is not active. Run: systemctl --user enable --now podman.socket" >&2
137
+ exit 1
138
+ fi
139
+ export LL_PODMAN_SOCKET="$(podman info --format '{{.Host.RemoteSocket.Path}}')"
140
+ fi
141
+
137
142
  # Test the Jenkinsfile on the branch we're actually on: sbomaas-multi clones
138
143
  # SBOMAAS_JENKINSFILE_REPO_BRANCH from the remote and `git push` below
139
144
  # publishes the current branch — so pin the clone branch to the current
140
145
  # checkout, overriding the fixed default from .env.dev.
141
146
  export SBOMAAS_JENKINSFILE_REPO_BRANCH="$(git branch --show-current)"
142
147
 
143
- python scripts/update_images_in_jenkinsfile.py --dry-run
148
+ # Advance the Jenkinsfile's sbomaas image pins to the newest published semver
149
+ # (via skopeo) before the pipeline clones it, so e2e always runs against the
150
+ # latest images. No-op when already current; commits + pushes only on a bump
151
+ # (which then names the version, so a red run points at the culprit).
152
+ python scripts/update_images_in_jenkinsfile.py
144
153
 
145
154
  # sbomaas-multi clones the Jenkinsfile from the bitbucket remote, so any
146
155
  # local edits to $SBOMAAS_JENKINSFILE_PATH_IN_REPO must be pushed first.
File without changes