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

Show generate-shell-completion command in uv help #6180

Merged
merged 2 commits into from
Aug 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion crates/uv/src/commands/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@ use super::ExitStatus;
use crate::printer::Printer;
use uv_cli::Cli;

// hidden subcommands to show in the help command
const SHOW_HIDDEN_COMMANDS: &[&str] = &["generate-shell-completion"];

pub(crate) fn help(query: &[String], printer: Printer, no_pager: bool) -> Result<ExitStatus> {
let mut uv = Cli::command();
let mut uv: clap::Command = SHOW_HIDDEN_COMMANDS
.iter()
.fold(Cli::command(), |uv, &name| {
uv.mut_subcommand(name, |cmd| cmd.hide(false))
});

// It is very important to build the command before beginning inspection or subcommands
// will be missing all of the propagated options.
Expand Down
89 changes: 47 additions & 42 deletions crates/uv/tests/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,21 @@ fn help() {
Usage: uv [OPTIONS] <COMMAND>

Commands:
run Run a command or script (experimental)
init Create a new project (experimental)
add Add dependencies to the project (experimental)
remove Remove dependencies from the project (experimental)
sync Update the project's environment (experimental)
lock Update the project's lockfile (experimental)
tree Display the project's dependency tree (experimental)
tool Run and install commands provided by Python packages (experimental)
python Manage Python versions and installations (experimental)
pip Manage Python packages with a pip-compatible interface
venv Create a virtual environment
cache Manage uv's cache
version Display uv's version
help Display documentation for a command
run Run a command or script (experimental)
init Create a new project (experimental)
add Add dependencies to the project (experimental)
remove Remove dependencies from the project (experimental)
sync Update the project's environment (experimental)
lock Update the project's lockfile (experimental)
tree Display the project's dependency tree (experimental)
tool Run and install commands provided by Python packages (experimental)
python Manage Python versions and installations (experimental)
pip Manage Python packages with a pip-compatible interface
venv Create a virtual environment
cache Manage uv's cache
version Display uv's version
generate-shell-completion Generate shell completion
help Display documentation for a command

Cache options:
-n, --no-cache Avoid reading from or writing to the cache, instead using a temporary
Expand Down Expand Up @@ -632,6 +633,7 @@ fn help_unknown_subcommand() {
venv
cache
version
generate-shell-completion
"###);

uv_snapshot!(context.filters(), context.help().arg("foo").arg("bar"), @r###"
Expand All @@ -654,6 +656,7 @@ fn help_unknown_subcommand() {
venv
cache
version
generate-shell-completion
"###);
}

Expand Down Expand Up @@ -690,20 +693,21 @@ fn help_with_global_option() {
Usage: uv [OPTIONS] <COMMAND>

Commands:
run Run a command or script (experimental)
init Create a new project (experimental)
add Add dependencies to the project (experimental)
remove Remove dependencies from the project (experimental)
sync Update the project's environment (experimental)
lock Update the project's lockfile (experimental)
tree Display the project's dependency tree (experimental)
tool Run and install commands provided by Python packages (experimental)
python Manage Python versions and installations (experimental)
pip Manage Python packages with a pip-compatible interface
venv Create a virtual environment
cache Manage uv's cache
version Display uv's version
help Display documentation for a command
run Run a command or script (experimental)
init Create a new project (experimental)
add Add dependencies to the project (experimental)
remove Remove dependencies from the project (experimental)
sync Update the project's environment (experimental)
lock Update the project's lockfile (experimental)
tree Display the project's dependency tree (experimental)
tool Run and install commands provided by Python packages (experimental)
python Manage Python versions and installations (experimental)
pip Manage Python packages with a pip-compatible interface
venv Create a virtual environment
cache Manage uv's cache
version Display uv's version
generate-shell-completion Generate shell completion
help Display documentation for a command

Cache options:
-n, --no-cache Avoid reading from or writing to the cache, instead using a temporary
Expand Down Expand Up @@ -788,20 +792,21 @@ fn help_with_no_pager() {
Usage: uv [OPTIONS] <COMMAND>

Commands:
run Run a command or script (experimental)
init Create a new project (experimental)
add Add dependencies to the project (experimental)
remove Remove dependencies from the project (experimental)
sync Update the project's environment (experimental)
lock Update the project's lockfile (experimental)
tree Display the project's dependency tree (experimental)
tool Run and install commands provided by Python packages (experimental)
python Manage Python versions and installations (experimental)
pip Manage Python packages with a pip-compatible interface
venv Create a virtual environment
cache Manage uv's cache
version Display uv's version
help Display documentation for a command
run Run a command or script (experimental)
init Create a new project (experimental)
add Add dependencies to the project (experimental)
remove Remove dependencies from the project (experimental)
sync Update the project's environment (experimental)
lock Update the project's lockfile (experimental)
tree Display the project's dependency tree (experimental)
tool Run and install commands provided by Python packages (experimental)
python Manage Python versions and installations (experimental)
pip Manage Python packages with a pip-compatible interface
venv Create a virtual environment
cache Manage uv's cache
version Display uv's version
generate-shell-completion Generate shell completion
help Display documentation for a command

Cache options:
-n, --no-cache Avoid reading from or writing to the cache, instead using a temporary
Expand Down
Loading