add -u and -p option to login commnand.

This commit is contained in:
2024-02-09 18:22:13 +09:00
parent ce0a608db2
commit c3e2dfbd8e
3 changed files with 55 additions and 51 deletions

View File

@ -13,14 +13,16 @@ class LoginCommand(BaseCommand):
@classmethod
def register(cls, parsers: Any) -> None:
login_parser = parsers.add_parser("login", help="login to remote host")
login_parser.add_argument("-u", "--username", help="login username")
login_parser.add_argument("-p", "--password", help="login password")
login_parser.add_argument("remote", help="label of remote host")
login_parser.set_defaults(func=cls.func)
@classmethod
def func(cls, args: Namespace) -> None:
remote = str(args.remote)
username = input("Username: ").strip()
password = getpass.getpass("Password: ").strip()
username = str(args.username) if args.password else input("Username: ").strip()
password = str(args.password) if args.password else getpass.getpass("Password: ").strip()
cls.login(remote, username, password)
@classmethod