clan-cli ssh: --json can be file or str
This commit is contained in:
@@ -3,6 +3,7 @@ import json
|
|||||||
import logging
|
import logging
|
||||||
import socket
|
import socket
|
||||||
import subprocess
|
import subprocess
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from ..nix import nix_shell
|
from ..nix import nix_shell
|
||||||
|
|
||||||
@@ -97,8 +98,11 @@ def connect_ssh_from_json(ssh_data: dict[str, str]) -> None:
|
|||||||
|
|
||||||
def main(args: argparse.Namespace) -> None:
|
def main(args: argparse.Namespace) -> None:
|
||||||
if args.json:
|
if args.json:
|
||||||
with open(args.json) as file:
|
json_file = Path(args.json)
|
||||||
ssh_data = json.load(file)
|
if json_file.is_file():
|
||||||
|
ssh_data = json.loads(json_file.read_text())
|
||||||
|
else:
|
||||||
|
ssh_data = json.loads(args.json)
|
||||||
connect_ssh_from_json(ssh_data)
|
connect_ssh_from_json(ssh_data)
|
||||||
elif args.png:
|
elif args.png:
|
||||||
ssh_data = json.loads(qrcode_scan(args.png))
|
ssh_data = json.loads(qrcode_scan(args.png))
|
||||||
|
|||||||
Reference in New Issue
Block a user