From 17c846897e2de7338a6eda772fbdeb497ad96895 Mon Sep 17 00:00:00 2001 From: Evan Pratten Date: Mon, 23 Oct 2023 09:52:43 -0400 Subject: [PATCH] Add reconnect option --- configs/scripts/guru-vpn | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/configs/scripts/guru-vpn b/configs/scripts/guru-vpn index b6ede10..b974c6b 100755 --- a/configs/scripts/guru-vpn +++ b/configs/scripts/guru-vpn @@ -108,17 +108,23 @@ def main() -> int: prog="guru-vpn", description="Utility for connecting to the Guru VPN" ) ap.add_argument( - "operation", choices=["connect", "disconnect"], help="Operation to perform" + "operation", + choices=["connect", "disconnect", "reconnect"], + help="Operation to perform", ) args = ap.parse_args() # Ensure we can actually get credentials from the Yubikey if not has_ykman(): - print("Could not execute `ykman`. Is it installed?", file=sys.stderr); + print("Could not execute `ykman`. Is it installed?", file=sys.stderr) return 1 # Handle subcommands - cmd_fns = {"connect": handle_connect, "disconnect": handle_disconnect} + cmd_fns = { + "connect": handle_connect, + "disconnect": handle_disconnect, + "reconnect": lambda args: handle_disconnect(args) or handle_connect(args), + } return cmd_fns[args.operation](args)