This commit is contained in:
Jeffrey C. Ollie 2023-10-30 14:07:30 -05:00
parent 6b0a4f7b9c
commit 7d70e72516
Signed by: jeff
GPG key ID: 6F86035A6D97044E

View file

@ -62,20 +62,12 @@ Config = TypeAdapter(dict[str, Entry])
@click.option("--ssh-command", default="ssh") @click.option("--ssh-command", default="ssh")
@click.option("--telnet-command", default="telnet") @click.option("--telnet-command", default="telnet")
@click.option("--config", type=click.Path(exists=True, path_type=pathlib.Path)) @click.option("--config", type=click.Path(exists=True, path_type=pathlib.Path))
@click.option("--name", type=str)
def main( def main(
ssh_command: str, ssh_command: str,
telnet_command: str, telnet_command: str,
config: pathlib.Path, config: pathlib.Path,
name: str,
): ):
cfg = Config.validate_json(config.read_bytes()) entry = Entry.validate_model_json(config.read_bytes())
if name not in cfg:
sys.stderr.write("unknown config entry!\n")
sys.exit(1)
entry = cfg[name]
a = pyansi.ANSI() a = pyansi.ANSI()
sys.stdout.write(a.Title(text=f"{entry.name} - {entry.address}")) sys.stdout.write(a.Title(text=f"{entry.name} - {entry.address}"))