mirror of https://github.com/astral-sh/uv
Add value hints to command line arguments to improve shell completion accuracy (#17080)
## Summary This partially addresses #17076 by adding `value_hint` to various arguments. For cases where an option takes a path to either specifically a file or a directory directory, `ValueHint::FilePath` and `ValueHint::DirPath` are used respectively to try to limit the amount of noise presented by completions in shells which support it. For cases where a URL (and only a URL, not a path) can be supplied, `ValueHint::Url` is used. For cases where a python interpreter is to be specified, `ValueHint::CommandName` is used which will tab complete from `$PATH` by default, but will fall back to completing executable filenames if you start typing a path. Finally, for the many cases where there is no built in completion which would make sense, and where default completion of a path would make no sense (e.g. a package name, or version specifier, or date) `ValueHint::Other` is used to explicitly disable completion. ## Test Plan Manually tested a bunch of these. These _could_ be automated in the sense that we could snapshot the completion from zsh but I've not thought about how that could be done yet.
This commit is contained in:
parent
af95677b9b
commit
94c97b6434
|
|
@ -3,7 +3,7 @@ use std::path::{Path, PathBuf};
|
||||||
use uv_static::EnvVars;
|
use uv_static::EnvVars;
|
||||||
|
|
||||||
use crate::Cache;
|
use crate::Cache;
|
||||||
use clap::Parser;
|
use clap::{Parser, ValueHint};
|
||||||
use tracing::{debug, warn};
|
use tracing::{debug, warn};
|
||||||
|
|
||||||
#[derive(Parser, Debug, Clone)]
|
#[derive(Parser, Debug, Clone)]
|
||||||
|
|
@ -27,7 +27,7 @@ pub struct CacheArgs {
|
||||||
/// `%LOCALAPPDATA%\uv\cache` on Windows.
|
/// `%LOCALAPPDATA%\uv\cache` on Windows.
|
||||||
///
|
///
|
||||||
/// To view the location of the cache directory, run `uv cache dir`.
|
/// To view the location of the cache directory, run `uv cache dir`.
|
||||||
#[arg(global = true, long, env = EnvVars::UV_CACHE_DIR)]
|
#[arg(global = true, long, env = EnvVars::UV_CACHE_DIR, value_hint = ValueHint::DirPath)]
|
||||||
pub cache_dir: Option<PathBuf>,
|
pub cache_dir: Option<PathBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue