runtime-sdk 0.4.23__tar.gz → 0.4.24__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: runtime-sdk
3
- Version: 0.4.23
3
+ Version: 0.4.24
4
4
  Summary: Runtime Python SDK and CLI
5
5
  Project-URL: Repository, https://github.com/The-Money-Company-Limited/runtimevm
6
6
  Project-URL: Issues, https://github.com/The-Money-Company-Limited/runtimevm/issues
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "runtime-sdk"
3
- version = "0.4.23"
3
+ version = "0.4.24"
4
4
  description = "Runtime Python SDK and CLI"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -325,6 +325,9 @@ def build_parser() -> argparse.ArgumentParser:
325
325
  )
326
326
  completion_cmd.add_argument("shell", choices=["bash", "zsh", "fish"], help="Target shell")
327
327
 
328
+ # Hidden helper used by shell completion to list slugs, one per line.
329
+ subparsers.add_parser("_slugs", help=argparse.SUPPRESS)
330
+
328
331
  parser.format_help = lambda: _format_top_help() # type: ignore[assignment]
329
332
  return parser
330
333
 
@@ -571,6 +574,8 @@ def main(argv: list[str] | None = None) -> int:
571
574
  return handle_help(args.topic)
572
575
  if args.command == "completion":
573
576
  return handle_completion(args.shell)
577
+ if args.command == "_slugs":
578
+ return handle_slugs(config)
574
579
  if args.command == "_proxy_agent":
575
580
  return run_proxy_agent(
576
581
  args.base_url,
@@ -3058,7 +3063,7 @@ def _vm_detail_menu(client: RuntimeClient, vm: dict[str, Any]) -> str:
3058
3063
  choices,
3059
3064
  ).unsafe_ask()
3060
3065
 
3061
- if action == "__back__":
3066
+ if action is None or action == "__back__":
3062
3067
  return "__back__"
3063
3068
  if action == "__quit__":
3064
3069
  return "__quit__"
@@ -3270,9 +3275,9 @@ _runtime_complete() {
3270
3275
  fi
3271
3276
  sub="${COMP_WORDS[1]}"
3272
3277
  case "$sub" in
3273
- info|url|start|enter|run|publish|delete|rm|share|startup|service)
3278
+ info|url|start|enter|run|publish|delete|rm|startup|service)
3274
3279
  local ids
3275
- ids=$(runtime ls 2>/dev/null | python3 -c 'import sys,json;print("\n".join(c["slug"] for c in json.load(sys.stdin).get("computers",[]) if c.get("slug")))' 2>/dev/null)
3280
+ ids=$(runtime _slugs 2>/dev/null)
3276
3281
  COMPREPLY=( $(compgen -W "$ids" -- "$cur") )
3277
3282
  ;;
3278
3283
  completion)
@@ -3281,6 +3286,10 @@ _runtime_complete() {
3281
3286
  share)
3282
3287
  if [[ ${COMP_CWORD} -eq 2 ]]; then
3283
3288
  COMPREPLY=( $(compgen -W "public private" -- "$cur") )
3289
+ else
3290
+ local ids
3291
+ ids=$(runtime _slugs 2>/dev/null)
3292
+ COMPREPLY=( $(compgen -W "$ids" -- "$cur") )
3284
3293
  fi
3285
3294
  ;;
3286
3295
  esac
@@ -3331,11 +3340,17 @@ _runtime() {
3331
3340
  case ${words[1]} in
3332
3341
  info|url|start|enter|run|publish|delete|rm|startup|service)
3333
3342
  local -a ids
3334
- ids=(${(f)"$(runtime ls 2>/dev/null | python3 -c 'import sys,json;print(\"\\n\".join(c[\"slug\"] for c in json.load(sys.stdin).get(\"computers\",[]) if c.get(\"slug\")))' 2>/dev/null)"})
3343
+ ids=(${(f)"$(runtime _slugs 2>/dev/null)"})
3335
3344
  _describe -t slugs 'computer' ids
3336
3345
  ;;
3337
3346
  share)
3338
- _values 'visibility' public private
3347
+ if (( CURRENT == 2 )); then
3348
+ _values 'visibility' public private
3349
+ else
3350
+ local -a ids
3351
+ ids=(${(f)"$(runtime _slugs 2>/dev/null)"})
3352
+ _describe -t slugs 'computer' ids
3353
+ fi
3339
3354
  ;;
3340
3355
  completion)
3341
3356
  _values 'shell' bash zsh fish
@@ -3350,7 +3365,7 @@ _runtime "$@"
3350
3365
 
3351
3366
  _COMPLETION_FISH = r"""# fish completion for runtime
3352
3367
  function __runtime_slugs
3353
- runtime ls 2>/dev/null | python3 -c 'import sys,json;print("\n".join(c["slug"] for c in json.load(sys.stdin).get("computers",[]) if c.get("slug")))' 2>/dev/null
3368
+ runtime _slugs 2>/dev/null
3354
3369
  end
3355
3370
 
3356
3371
  complete -c runtime -f
@@ -3387,5 +3402,25 @@ def handle_completion(shell: str) -> int:
3387
3402
  return 0
3388
3403
 
3389
3404
 
3405
+ def handle_slugs(config: RuntimeConfig) -> int:
3406
+ """Print one slug per line. Used by shell completion scripts. Silent on errors."""
3407
+ if not config.api_key:
3408
+ return 0
3409
+ try:
3410
+ client = RuntimeClient(base_url=config.base_url, api_key=config.api_key)
3411
+ payload = client.list_computers()
3412
+ except Exception:
3413
+ return 0
3414
+ computers = payload.get("computers") or []
3415
+ if not isinstance(computers, list):
3416
+ return 0
3417
+ for c in computers:
3418
+ if isinstance(c, dict):
3419
+ slug = str(c.get("slug") or "").strip()
3420
+ if slug:
3421
+ sys.stdout.write(slug + "\n")
3422
+ return 0
3423
+
3424
+
3390
3425
  if __name__ == "__main__":
3391
3426
  raise SystemExit(main())
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: runtime-sdk
3
- Version: 0.4.23
3
+ Version: 0.4.24
4
4
  Summary: Runtime Python SDK and CLI
5
5
  Project-URL: Repository, https://github.com/The-Money-Company-Limited/runtimevm
6
6
  Project-URL: Issues, https://github.com/The-Money-Company-Limited/runtimevm/issues
File without changes
File without changes