mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
Show the command summary when running cargo --list
This commit is contained in:
parent
c3422cfc40
commit
af2c355585
@ -70,8 +70,9 @@ Run with 'cargo -Z [FLAG] [SUBCOMMAND]'"
|
||||
println!("Installed Commands:");
|
||||
for command in list_commands(config) {
|
||||
match command {
|
||||
CommandInfo::BuiltIn { name } => {
|
||||
println!(" {:<20} {}", name)
|
||||
CommandInfo::BuiltIn { name, about } => {
|
||||
let summary = about.unwrap_or_default();
|
||||
println!(" {:<20} {}", name, summary)
|
||||
}
|
||||
CommandInfo::External { name, path } => {
|
||||
if is_verbose {
|
||||
|
@ -414,7 +414,7 @@ pub fn values(args: &ArgMatches, name: &str) -> Vec<String> {
|
||||
|
||||
#[derive(PartialEq, PartialOrd, Eq, Ord)]
|
||||
pub enum CommandInfo {
|
||||
BuiltIn { name: String },
|
||||
BuiltIn { name: String, about: Option<String>, },
|
||||
External { name: String, path: PathBuf },
|
||||
}
|
||||
|
||||
|
@ -114,6 +114,7 @@ fn list_commands(config: &Config) -> BTreeSet<CommandInfo> {
|
||||
for cmd in commands::builtin() {
|
||||
commands.insert(CommandInfo::BuiltIn {
|
||||
name: cmd.get_name().to_string(),
|
||||
about: cmd.p.meta.about.map(|s| s.to_string()),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -60,6 +60,18 @@ fn path() -> Vec<PathBuf> {
|
||||
env::split_paths(&env::var_os("PATH").unwrap_or_default()).collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn list_commands_with_descriptions() {
|
||||
let p = project().build();
|
||||
let output = p.cargo("--list").exec_with_output().unwrap();
|
||||
let output = str::from_utf8(&output.stdout).unwrap();
|
||||
assert!(
|
||||
output.contains("\n build Compile a local package and all of its dependencies"),
|
||||
"missing build, with description: {}",
|
||||
output
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn list_command_looks_at_path() {
|
||||
let proj = project().build();
|
||||
|
Loading…
x
Reference in New Issue
Block a user