1

Add reconnect option

This commit is contained in:
Evan Pratten 2023-10-23 09:52:43 -04:00
parent d036999c0c
commit 17c846897e

View File

@ -108,17 +108,23 @@ def main() -> int:
prog="guru-vpn", description="Utility for connecting to the Guru VPN" prog="guru-vpn", description="Utility for connecting to the Guru VPN"
) )
ap.add_argument( ap.add_argument(
"operation", choices=["connect", "disconnect"], help="Operation to perform" "operation",
choices=["connect", "disconnect", "reconnect"],
help="Operation to perform",
) )
args = ap.parse_args() args = ap.parse_args()
# Ensure we can actually get credentials from the Yubikey # Ensure we can actually get credentials from the Yubikey
if not has_ykman(): 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 return 1
# Handle subcommands # 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) return cmd_fns[args.operation](args)