diff --git a/src/huggingface_hub/commands/user.py b/src/huggingface_hub/commands/user.py index 9441f31b91..e631f1d41e 100644 --- a/src/huggingface_hub/commands/user.py +++ b/src/huggingface_hub/commands/user.py @@ -44,6 +44,16 @@ class UserCommands(BaseHuggingfaceCLICommand): @staticmethod def register_subcommand(parser: _SubParsersAction): login_parser = parser.add_parser("login", help="Log in using a token from huggingface.co/settings/tokens") + login_parser.add_argument( + "--token", + type=str, + help="Token generated from https://huggingface.co/settings/tokens", + ) + login_parser.add_argument( + "--add-to-git-credential", + action="store_true", + help="Optional: Save token to git credential helper.", + ) login_parser.set_defaults(func=lambda args: LoginCommand(args)) whoami_parser = parser.add_parser("whoami", help="Find out which huggingface.co account you are logged in as.") whoami_parser.set_defaults(func=lambda args: WhoamiCommand(args)) @@ -91,7 +101,7 @@ def __init__(self, args): class LoginCommand(BaseUserCommand): def run(self): - login() + login(token=self.args.token, add_to_git_credential=self.args.add_to_git_credential) class LogoutCommand(BaseUserCommand):