clan-cli/ssh: add tests + fixes

This commit is contained in:
DavHau
2023-07-25 15:16:05 +02:00
parent 202e07d5fe
commit 310bdacb9d
2 changed files with 35 additions and 29 deletions

View File

@@ -36,7 +36,7 @@ def ssh(
subprocess.run(cmd)
def qrcode_scan(pictureFile: str) -> dict:
def qrcode_scan(pictureFile: str) -> dict: # pragma: no cover
subprocess.Popen(
[
"nix",
@@ -52,7 +52,7 @@ def qrcode_scan(pictureFile: str) -> dict:
).stdout.read()
def main(args: argparse.Namespace) -> None:
def main(args: argparse.Namespace) -> None: # pragma: no cover
if args.json:
with open(args.json) as file:
ssh_data = json.load(file)
@@ -62,13 +62,15 @@ def main(args: argparse.Namespace) -> None:
ssh(host=ssh_data["address"], password=ssh_data["password"])
def register_parser(parser: argparse.ArgumentParser) -> None:
parser.add_argument(
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument(
"-j",
"--json",
help="specify the json file for ssh data (generated by starting the clan installer)",
)
parser.add_argument(
group.add_argument(
"-P",
"--png",
help="specify the json file for ssh data as the qrcode image (generated by starting the clan installer)",