Skip to content

Implement new hf CLI to replace huggingface-cli with modern syntax #3225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Jul 15, 2025

This PR implements a new hf CLI tool to replace the existing huggingface-cli with a more modern and consistent syntax, similar to the GitHub CLI. The new CLI maintains 100% backward compatibility while providing a cleaner interface.

New CLI Structure

The new hf CLI organizes commands into logical groups:

# Authentication commands
hf auth login
hf auth logout
hf auth switch
hf auth list
hf auth whoami

# Repository commands
hf repo create
hf repo tag create/delete/list

# File management commands
hf files download
hf files upload
hf files delete

# Cache management commands
hf cache scan
hf cache delete

# Utility commands
hf version
hf env

# Convenient aliases
hf download  # alias for hf files download
hf upload    # alias for hf files upload

Implementation Details

  • New CLI directory: Created src/huggingface_hub/cli/ with modular command structure
  • Entry point: Added hf=huggingface_hub.cli.hf_cli:main to setup.py
  • Backward compatibility: All existing huggingface-cli commands continue to work unchanged
  • Deprecation warnings: Old commands show yellow warnings pointing to new syntax
  • Code reuse: New CLI reuses existing command implementations for consistent behavior
  • Legacy support: Included specialized commands like lfs-enable-largefiles and upload-large-folder

Examples

Before (old CLI)

huggingface-cli login --token=hf_***
huggingface-cli download gpt2 config.json
huggingface-cli scan-cache
huggingface-cli tag create my-model v1.0

After (new CLI)

hf auth login --token=hf_***
hf files download gpt2 config.json
hf cache scan
hf repo tag create my-model v1.0

Testing

  • Added comprehensive test suite covering all command parsing scenarios
  • All existing tests continue to pass
  • Verified deprecation warnings work correctly
  • Confirmed new CLI provides same functionality without warnings

Migration Path

Users can gradually migrate to the new CLI at their own pace:

  • Old commands work exactly as before but show helpful deprecation warnings
  • New commands provide the same functionality with cleaner syntax
  • No breaking changes to existing workflows

Fixes #3224.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits July 15, 2025 13:27
Co-authored-by: Wauplin <11801849+Wauplin@users.noreply.github.com>
…ntation

Co-authored-by: Wauplin <11801849+Wauplin@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] [test] smoothly switch CLI to hf Implement new hf CLI to replace huggingface-cli with modern syntax Jul 15, 2025
@Copilot Copilot AI requested a review from Wauplin July 15, 2025 13:38
Copilot finished work on behalf of Wauplin July 15, 2025 13:38
@Wauplin
Copy link
Contributor

Wauplin commented Jul 17, 2025

closing in favor to #3229

@Wauplin Wauplin closed this Jul 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Smoothly switch CLI to hf
2 participants