Skip to content

Commit

Permalink
Add token and git credentials to login cli command (#1372)
Browse files Browse the repository at this point in the history
* Add token and git credentials to login cli command

* Apply suggestions from code review

---------

Co-authored-by: Lucain <lucainp@gmail.com>
  • Loading branch information
silvanocerza and Wauplin authored Mar 2, 2023
1 parent b93803f commit 318f1be
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/huggingface_hub/commands/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 318f1be

Please sign in to comment.