pyvolt-cli 0.5.1__tar.gz → 0.6.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyvolt-cli
3
- Version: 0.5.1
3
+ Version: 0.6.0
4
4
  Summary: The command-line companion to Pyvolt: managed Python deployments on infrastructure you actually own.
5
5
  Project-URL: Homepage, https://pyvolt.com
6
6
  Project-URL: Repository, https://github.com/pyvolt-hq/pyvolt-cli
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "pyvolt-cli"
7
- version = "0.5.1"
7
+ version = "0.6.0"
8
8
  description = "The command-line companion to Pyvolt: managed Python deployments on infrastructure you actually own."
9
9
  readme = "README.md"
10
10
  license = { text = "MIT" }
@@ -581,3 +581,56 @@ def open_(
581
581
  return
582
582
  console.print(f"Opening {site['dashboard_url']}")
583
583
  webbrowser.open(site["dashboard_url"])
584
+
585
+
586
+ # ---- SSH keys (#75) -----------------------------------------------------------
587
+
588
+ keys_app = typer.Typer(help="Manage the SSH public keys pushed to your servers.", no_args_is_help=True)
589
+ app.add_typer(keys_app, name="keys")
590
+
591
+
592
+ @keys_app.command("list")
593
+ def keys_list():
594
+ """List your SSH public keys."""
595
+ data = Api().get("/v1/ssh-keys")
596
+ if _emit(data):
597
+ return
598
+ if not data:
599
+ console.print("No SSH keys yet. Add one with [bold]pyvolt keys add[/bold].")
600
+ return
601
+ t = _table("ID", "NAME", "FINGERPRINT")
602
+ for k in data:
603
+ t.add_row(str(k["id"]), k["name"], k["fingerprint"])
604
+ console.print(t)
605
+
606
+
607
+ @keys_app.command("add")
608
+ def keys_add(
609
+ path: str = typer.Argument(None, metavar="PATH", help="Public key file (default: ~/.ssh/id_ed25519.pub)."),
610
+ name: str = typer.Option(None, "--name", "-n", help="Label for the key (default: its comment, else your hostname)."),
611
+ ):
612
+ """Add an SSH public key. Pushed to every ready server in your account."""
613
+ import socket
614
+ from pathlib import Path
615
+
616
+ p = Path(path).expanduser() if path else Path.home() / ".ssh" / "id_ed25519.pub"
617
+ if not p.exists():
618
+ raise fail(f"No public key at {p}. Pass a path, e.g. [bold]pyvolt keys add ~/.ssh/id_rsa.pub[/bold].")
619
+ pub = p.read_text().strip()
620
+ if not name:
621
+ parts = pub.split()
622
+ name = parts[2] if len(parts) >= 3 else socket.gethostname()
623
+ r = Api().post("/v1/ssh-keys", json={"name": name, "public_key": pub}, ok=(201, 422))
624
+ if r.status_code == 422:
625
+ raise fail(r.json().get("detail", "That doesn't look like an SSH public key."))
626
+ key = r.json()
627
+ if _emit(key):
628
+ return
629
+ console.print(f"[green]✓[/green] Added [bold]{key['name']}[/bold] ({key['fingerprint']}). Syncing to your servers.")
630
+
631
+
632
+ @keys_app.command("rm")
633
+ def keys_rm(key_id: int = typer.Argument(..., metavar="ID", help="Key ID from `pyvolt keys list`.")):
634
+ """Remove an SSH public key by ID."""
635
+ Api().delete(f"/v1/ssh-keys/{key_id}")
636
+ console.print(f"[green]✓[/green] Removed key {key_id}. Re-syncing your servers.")
File without changes
File without changes
File without changes