Tweak the help message
authorAleksey Kladov <aleksey.kladov@gmail.com>
Sat, 10 Mar 2018 14:35:18 +0000 (17:35 +0300)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Sat, 10 Mar 2018 14:35:18 +0000 (17:35 +0300)
src/bin/cli.rs

index 7e5c45538f24098e31dc1d2fd3e40ae88decc08c..d24ad2fc3449d6184d500386d937f9bdc77c0e39 100644 (file)
@@ -69,6 +69,11 @@ pub fn do_main(config: &mut Config) -> CliResult {
         return Ok(());
     }
 
+    if args.subcommand_name().is_none() {
+        cli().print_help()?;
+        return Ok(());
+    }
+
     execute_subcommand(config, args)
 }
 
@@ -566,13 +571,39 @@ fn execute_subcommand(config: &mut Config, args: ArgMatches) -> CliResult {
 fn cli() -> App {
     let app = App::new("cargo")
         .settings(&[
-            AppSettings::DisableVersion,
             AppSettings::UnifiedHelpMessage,
             AppSettings::DeriveDisplayOrder,
             AppSettings::VersionlessSubcommands,
             AppSettings::AllowExternalSubcommands,
         ])
-        .about("Rust's package manager")
+        .about("")
+        .template("\
+Rust's package manager
+
+USAGE:
+    {usage}
+
+OPTIONS:
+{unified}
+
+Some common cargo commands are (see all commands with --list):
+    build       Compile the current project
+    check       Analyze the current project and report errors, but don't build object files
+    clean       Remove the target directory
+    doc         Build this project's and its dependencies' documentation
+    new         Create a new cargo project
+    init        Create a new cargo project in an existing directory
+    run         Build and execute src/main.rs
+    test        Run the tests
+    bench       Run the benchmarks
+    update      Update dependencies listed in Cargo.lock
+    search      Search registry for crates
+    publish     Package and upload this project to the registry
+    install     Install a Rust binary
+    uninstall   Uninstall a Rust binary
+
+See 'cargo help <command>' for more information on a specific command."
+        )
         .arg(
             opt("version", "Print version info and exit")
                 .short("V")
@@ -608,25 +639,6 @@ fn cli() -> App {
             Arg::with_name("unstable-features").help("Unstable (nightly-only) flags to Cargo")
                 .short("Z").value_name("FLAG").multiple(true).global(true)
         )
-        .after_help("\
-Some common cargo commands are (see all commands with --list):
-    build       Compile the current project
-    check       Analyze the current project and report errors, but don't build object files
-    clean       Remove the target directory
-    doc         Build this project's and its dependencies' documentation
-    new         Create a new cargo project
-    init        Create a new cargo project in an existing directory
-    run         Build and execute src/main.rs
-    test        Run the tests
-    bench       Run the benchmarks
-    update      Update dependencies listed in Cargo.lock
-    search      Search registry for crates
-    publish     Package and upload this project to the registry
-    install     Install a Rust binary
-    uninstall   Uninstall a Rust binary
-
-See 'cargo help <command>' for more information on a specific command.
-")
         .subcommands(commands::builtin())
     ;
     app