]> git.proxmox.com Git - cargo.git/blobdiff - src/bin/cargo/commands/mod.rs
refactor(cli): Make help behave like other subcommands
[cargo.git] / src / bin / cargo / commands / mod.rs
index 3f7e4bf26e274557e0c4e37be67b4338614b965c..0499f9a437f528cc7444b1938f7e59c5c627f066 100644 (file)
@@ -1,20 +1,24 @@
-use command_prelude::*;
+use crate::command_prelude::*;
 
 pub fn builtin() -> Vec<App> {
     vec![
+        add::cli(),
         bench::cli(),
         build::cli(),
         check::cli(),
         clean::cli(),
+        config::cli(),
         doc::cli(),
         fetch::cli(),
         fix::cli(),
         generate_lockfile::cli(),
         git_checkout::cli(),
+        help::cli(),
         init::cli(),
         install::cli(),
         locate_project::cli(),
         login::cli(),
+        logout::cli(),
         metadata::cli(),
         new::cli(),
         owner::cli(),
@@ -22,39 +26,41 @@ pub fn builtin() -> Vec<App> {
         pkgid::cli(),
         publish::cli(),
         read_manifest::cli(),
+        report::cli(),
         run::cli(),
         rustc::cli(),
         rustdoc::cli(),
         search::cli(),
         test::cli(),
+        tree::cli(),
         uninstall::cli(),
         update::cli(),
+        vendor::cli(),
         verify_project::cli(),
         version::cli(),
         yank::cli(),
     ]
 }
 
-pub struct BuiltinExec<'a> {
-    pub exec: fn(&'a mut Config, &'a ArgMatches) -> CliResult,
-    pub alias_for: Option<&'static str>,
-}
-
-pub fn builtin_exec(cmd: &str) -> Option<BuiltinExec> {
-    let exec = match cmd {
+pub fn builtin_exec(cmd: &str) -> Option<fn(&mut Config, &ArgMatches) -> CliResult> {
+    let f = match cmd {
+        "add" => add::exec,
         "bench" => bench::exec,
-        "build" | "b" => build::exec,
-        "check" | "c" => check::exec,
+        "build" => build::exec,
+        "check" => check::exec,
         "clean" => clean::exec,
+        "config" => config::exec,
         "doc" => doc::exec,
         "fetch" => fetch::exec,
         "fix" => fix::exec,
         "generate-lockfile" => generate_lockfile::exec,
         "git-checkout" => git_checkout::exec,
+        "help" => help::exec,
         "init" => init::exec,
         "install" => install::exec,
         "locate-project" => locate_project::exec,
         "login" => login::exec,
+        "logout" => logout::exec,
         "metadata" => metadata::exec,
         "new" => new::exec,
         "owner" => owner::exec,
@@ -62,43 +68,41 @@ pub fn builtin_exec(cmd: &str) -> Option<BuiltinExec> {
         "pkgid" => pkgid::exec,
         "publish" => publish::exec,
         "read-manifest" => read_manifest::exec,
-        "run" | "r" => run::exec,
+        "report" => report::exec,
+        "run" => run::exec,
         "rustc" => rustc::exec,
         "rustdoc" => rustdoc::exec,
         "search" => search::exec,
-        "test" | "t" => test::exec,
+        "test" => test::exec,
+        "tree" => tree::exec,
         "uninstall" => uninstall::exec,
         "update" => update::exec,
+        "vendor" => vendor::exec,
         "verify-project" => verify_project::exec,
         "version" => version::exec,
         "yank" => yank::exec,
         _ => return None,
     };
-
-    let alias_for = match cmd {
-        "b" => Some("build"),
-        "c" => Some("check"),
-        "r" => Some("run"),
-        "t" => Some("test"),
-        _ => None,
-    };
-
-    Some(BuiltinExec { exec, alias_for })
+    Some(f)
 }
 
+pub mod add;
 pub mod bench;
 pub mod build;
 pub mod check;
 pub mod clean;
+pub mod config;
 pub mod doc;
 pub mod fetch;
 pub mod fix;
 pub mod generate_lockfile;
 pub mod git_checkout;
+pub mod help;
 pub mod init;
 pub mod install;
 pub mod locate_project;
 pub mod login;
+pub mod logout;
 pub mod metadata;
 pub mod new;
 pub mod owner;
@@ -106,13 +110,16 @@ pub mod package;
 pub mod pkgid;
 pub mod publish;
 pub mod read_manifest;
+pub mod report;
 pub mod run;
 pub mod rustc;
 pub mod rustdoc;
 pub mod search;
 pub mod test;
+pub mod tree;
 pub mod uninstall;
 pub mod update;
+pub mod vendor;
 pub mod verify_project;
 pub mod version;
 pub mod yank;