Skip to content

Commit f9bc1cb

Browse files
authored
[CLI] print help if no command provided (#3262)
1 parent 8f5292e commit f9bc1cb

File tree

5 files changed

+16
-5
lines changed

5 files changed

+16
-5
lines changed

src/huggingface_hub/cli/auth.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ def register_subcommand(parser: _SubParsersAction):
6262
auth_parser = parser.add_parser("auth", help="Manage authentication (login, logout, etc.).")
6363
auth_subparsers = auth_parser.add_subparsers(help="Authentication subcommands")
6464

65+
# Show help if no subcommand is provided
66+
auth_parser.set_defaults(func=lambda args: auth_parser.print_help())
67+
6568
# Add 'login' as a subcommand of 'auth'
6669
login_parser = auth_subparsers.add_parser(
6770
"login", help="Log in using a token from huggingface.co/settings/tokens"

src/huggingface_hub/cli/cache.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ class CacheCommand(BaseHuggingfaceCLICommand):
6565
def register_subcommand(parser: _SubParsersAction):
6666
cache_parser = parser.add_parser("cache", help="Manage local cache directory.")
6767
cache_subparsers = cache_parser.add_subparsers(dest="cache_command", help="Cache subcommands")
68+
69+
# Show help if no subcommand is provided
70+
cache_parser.set_defaults(func=lambda args: cache_parser.print_help())
71+
6872
# Scan subcommand
6973
scan_parser = cache_subparsers.add_parser("scan", help="Scan cache directory.")
7074
scan_parser.add_argument(

src/huggingface_hub/cli/hf.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@ def main():
4747
# LFS commands (hidden in --help)
4848
LfsCommands.register_subcommand(commands_parser)
4949

50-
# Legacy commands
51-
52-
# Experimental
53-
5450
# Let's go
5551
args = parser.parse_args()
5652
if not hasattr(args, "func"):
@@ -59,7 +55,8 @@ def main():
5955

6056
# Run
6157
service = args.func(args)
62-
service.run()
58+
if service is not None:
59+
service.run()
6360

6461

6562
if __name__ == "__main__":

src/huggingface_hub/cli/jobs.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ def register_subcommand(parser: _SubParsersAction):
5858
jobs_parser = parser.add_parser("jobs", help="Run and manage Jobs on the Hub.")
5959
jobs_subparsers = jobs_parser.add_subparsers(help="huggingface.co jobs related commands")
6060

61+
# Show help if no subcommand is provided
62+
jobs_parser.set_defaults(func=lambda args: jobs_parser.print_help())
63+
6164
# Register commands
6265
InspectCommand.register_subcommand(jobs_subparsers)
6366
LogsCommand.register_subcommand(jobs_subparsers)

src/huggingface_hub/cli/repo.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ class RepoCommands(BaseHuggingfaceCLICommand):
4343
def register_subcommand(parser: _SubParsersAction):
4444
repo_parser = parser.add_parser("repo", help="Manage repos on the Hub.")
4545
repo_subparsers = repo_parser.add_subparsers(help="huggingface.co repos related commands")
46+
47+
# Show help if no subcommand is provided
48+
repo_parser.set_defaults(func=lambda args: repo_parser.print_help())
49+
4650
# CREATE
4751
repo_create_parser = repo_subparsers.add_parser("create", help="Create a new repo on huggingface.co")
4852
repo_create_parser.add_argument(

0 commit comments

Comments
 (0)