Skip to content
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

Implement uv help manually instead of using Clap default #4906

Merged
merged 1 commit into from
Jul 9, 2024

Conversation

zanieb
Copy link
Member

@zanieb zanieb commented Jul 8, 2024

Extends #4772

Implements uv help ourselves so we can do things like #4909
Adds hints to use uv help for more details during short help display.

@zanieb zanieb added the cli Related to the command line interface label Jul 8, 2024
crates/uv/tests/help.rs Outdated Show resolved Hide resolved
@zanieb zanieb force-pushed the zb/cli-help-cmd branch 2 times, most recently from bd5670c to 0344631 Compare July 8, 2024 21:17
@zanieb zanieb marked this pull request as ready for review July 9, 2024 00:28
crates/uv/tests/help.rs Outdated Show resolved Hide resolved
Copy link
Member

@konstin konstin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found a way to make it panic, but i do like the more concise help a lot.

$ cargo run -q -- help pip install
thread 'main' panicked at /home/konsti/.cargo/registry/src/index.crates.io-6f17d22bba15001f/clap_builder-4.5.8/src/builder/debug_asserts.rs:214:13:
Command install: Argument or group 'offline' specified in 'conflicts_with*' for 'refresh' does not exist
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

zanieb added a commit that referenced this pull request Jul 9, 2024
I feel like I'm always drowning in the help output from `uv` because we
have so many options.

I basically agree with the commentary in
clap-rs/clap#4687 that having different
behaviors for `-h` and `--help` is surprising. I think `--help` is more
obvious for users and I want to optimize for that experience.

This roughly matches the help menus in Cargo and pip.

The `uv help` command can be used for long help. In #4906 and #4909 we
improve that command.

Extends #4904 which adds test cases for the existing behavior.
Base automatically changed from zb/cli-help to main July 9, 2024 17:12
@zanieb
Copy link
Member Author

zanieb commented Jul 9, 2024

Fixed the panic :)

@charliermarsh
Copy link
Member

Should these be different?

puffin on  zb/cli-help-cmd [$] is 📦 v0.2.23 via 🐍 v3.12.3 via 🦀 v1.79.0
❯ cargo run -- python --help
   Compiling uv-cli v0.0.1 (/Users/crmarsh/workspace/puffin/crates/uv-cli)
   Compiling uv v0.2.23 (/Users/crmarsh/workspace/puffin/crates/uv)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 2.81s
     Running `target/debug/uv python --help`
Manage Python installations

Usage: uv python [OPTIONS] <COMMAND>

Commands:
  list       List the available Python installations
  install    Download and install Python versions
  find       Search for a Python installation
  dir        Show the uv Python installation directory
  uninstall  Uninstall Python versions

Options:
  -q, --quiet                                  Do not print any output
  -v, --verbose...                             Use verbose output
      --color <COLOR_CHOICE>                   Control colors in output [default: auto] [possible values: auto, always, never]
      --native-tls                             Whether to load TLS certificates from the platform's native certificate store [env: UV_NATIVE_TLS=]
      --offline                                Disable network access, relying only on locally cached data and locally available files
      --python-preference <PYTHON_PREFERENCE>  Whether to prefer using Python from uv or on the system [possible values: only-managed, installed, managed, system, only-system]
      --python-fetch <PYTHON_FETCH>            Whether to automatically download Python when required [possible values: automatic, manual]
  -n, --no-cache                               Avoid reading from or writing to the cache [env: UV_NO_CACHE=]
      --cache-dir <CACHE_DIR>                  Path to the cache directory [env: UV_CACHE_DIR=]
      --config-file <CONFIG_FILE>              The path to a `uv.toml` file to use for configuration [env: UV_CONFIG_FILE=]
  -h, --help                                   Print help
  -V, --version                                Print version

Use `uv help python` for more details.
puffin on  zb/cli-help-cmd [$] is 📦 v0.2.23 via 🐍 v3.12.3 via 🦀 v1.79.0 took 3s
❯ cargo run -- help python
   Compiling uv-cli v0.0.1 (/Users/crmarsh/workspace/puffin/crates/uv-cli)
   Compiling uv v0.2.23 (/Users/crmarsh/workspace/puffin/crates/uv)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 2.83s
     Running `target/debug/uv help python`
Manage Python installations

Usage: python <COMMAND>

Commands:
  list       List the available Python installations
  install    Download and install Python versions
  find       Search for a Python installation
  dir        Show the uv Python installation directory
  uninstall  Uninstall Python versions
  help       Print this message or the help of the given subcommand(s)

Options:
  -h, --help
          Print help (see a summary with '-h')

@zanieb
Copy link
Member Author

zanieb commented Jul 9, 2024

Yes they should be different but we should be displaying the long-form documentation for all those options in the second invocation. Will investigate that...

@zanieb
Copy link
Member Author

zanieb commented Jul 9, 2024

Ah I pushed a fix to #4909 but not here by accident.

@zanieb zanieb enabled auto-merge (squash) July 9, 2024 17:41
@zanieb zanieb merged commit 5f20bdb into main Jul 9, 2024
49 checks passed
@zanieb zanieb deleted the zb/cli-help-cmd branch July 9, 2024 17:43
zanieb added a commit that referenced this pull request Jul 9, 2024
Extends #4906

Adds paged display of "long' help to `uv help` invocations when `less`
or `more` is available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli Related to the command line interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants