From fab6588f8a39662b6390c89b919e705c20924148 Mon Sep 17 00:00:00 2001 From: Martin Geisler Date: Mon, 24 Jul 2017 01:29:40 +0200 Subject: [PATCH] Consistently give toolchain argument a help text This adds a help text to every toolchain command line argument. The help text for 'rustup default' now reads: rustup-default Set the default toolchain USAGE: rustup default FLAGS: -h, --help Prints help information ARGS: Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see `rustup help toolchain` DISCUSSION: Sets the default toolchain to the one specified. If the toolchain is not already installed then it is installed first. Two commands (update and install) already explained what the toolchain argument was -- but it was explained in the freeform "after help" text. These explanations have been moved to the arguments themselves for consistency. Fixes #923. --- src/rustup-cli/help.rs | 17 +++++++---------- src/rustup-cli/rustup_mode.rs | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/rustup-cli/help.rs b/src/rustup-cli/help.rs index 88938c8f8c..da1d9a15f7 100644 --- a/src/rustup-cli/help.rs +++ b/src/rustup-cli/help.rs @@ -26,21 +26,13 @@ r"DISCUSSION: updates rustup itself. If given a toolchain argument then `update` updates that - toolchain, the same as `rustup toolchain install`. - - 'toolchain' specifies a toolchain name, such as 'stable', - 'nightly', or '1.8.0'. For more information see `rustup help - toolchain`."; + toolchain, the same as `rustup toolchain install`."; pub static INSTALL_HELP: &'static str = r"DISCUSSION: Installs a specific rust toolchain. - The 'install' command is an alias for 'rustup update '. - - 'toolchain' specifies a toolchain name, such as 'stable', - 'nightly', or '1.8.0'. For more information see `rustup help - toolchain`."; + The 'install' command is an alias for 'rustup update '."; pub static DEFAULT_HELP: &'static str = r"DISCUSSION: @@ -260,3 +252,8 @@ r"DISCUSSION: completions into our profile simply use PS C:\> rustup completions powershell >> %USERPROFILE%\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1"; + +pub static TOOLCHAIN_ARG_HELP: &'static str = + "Toolchain name, such as 'stable', 'nightly', \ + or '1.8.0'. For more information see `rustup \ + help toolchain`"; diff --git a/src/rustup-cli/rustup_mode.rs b/src/rustup-cli/rustup_mode.rs index 273ba75c59..f306f57daa 100644 --- a/src/rustup-cli/rustup_mode.rs +++ b/src/rustup-cli/rustup_mode.rs @@ -123,18 +123,21 @@ pub fn cli() -> App<'static, 'static> { .after_help(INSTALL_HELP) .setting(AppSettings::Hidden) // synonym for 'toolchain install' .arg(Arg::with_name("toolchain") + .help(TOOLCHAIN_ARG_HELP) .required(true) .multiple(true))) .subcommand(SubCommand::with_name("uninstall") .about("Uninstall Rust toolchains") .setting(AppSettings::Hidden) // synonym for 'toolchain uninstall' .arg(Arg::with_name("toolchain") + .help(TOOLCHAIN_ARG_HELP) .required(true) .multiple(true))) .subcommand(SubCommand::with_name("update") .about("Update Rust toolchains and rustup") .after_help(UPDATE_HELP) .arg(Arg::with_name("toolchain") + .help(TOOLCHAIN_ARG_HELP) .required(false) .multiple(true)) .arg(Arg::with_name("no-self-update") @@ -146,6 +149,7 @@ pub fn cli() -> App<'static, 'static> { .about("Set the default toolchain") .after_help(DEFAULT_HELP) .arg(Arg::with_name("toolchain") + .help(TOOLCHAIN_ARG_HELP) .required(true))) .subcommand(SubCommand::with_name("toolchain") .about("Modify or query the installed toolchains") @@ -159,18 +163,21 @@ pub fn cli() -> App<'static, 'static> { .about("Install or update a given toolchain") .aliases(&["update", "add"]) .arg(Arg::with_name("toolchain") + .help(TOOLCHAIN_ARG_HELP) .required(true) .multiple(true))) .subcommand(SubCommand::with_name("uninstall") .about("Uninstall a toolchain") .alias("remove") .arg(Arg::with_name("toolchain") + .help(TOOLCHAIN_ARG_HELP) .required(true) .multiple(true))) .subcommand(SubCommand::with_name("link") .about("Create a custom toolchain by symlinking to a directory") .after_help(TOOLCHAIN_LINK_HELP) .arg(Arg::with_name("toolchain") + .help(TOOLCHAIN_ARG_HELP) .required(true)) .arg(Arg::with_name("path") .required(true)))) @@ -182,6 +189,7 @@ pub fn cli() -> App<'static, 'static> { .subcommand(SubCommand::with_name("list") .about("List installed and available targets") .arg(Arg::with_name("toolchain") + .help(TOOLCHAIN_ARG_HELP) .long("toolchain") .takes_value(true))) .subcommand(SubCommand::with_name("add") @@ -191,6 +199,7 @@ pub fn cli() -> App<'static, 'static> { .required(true) .multiple(true)) .arg(Arg::with_name("toolchain") + .help(TOOLCHAIN_ARG_HELP) .long("toolchain") .takes_value(true))) .subcommand(SubCommand::with_name("remove") @@ -200,6 +209,7 @@ pub fn cli() -> App<'static, 'static> { .required(true) .multiple(true)) .arg(Arg::with_name("toolchain") + .help(TOOLCHAIN_ARG_HELP) .long("toolchain") .takes_value(true)))) .subcommand(SubCommand::with_name("component") @@ -210,6 +220,7 @@ pub fn cli() -> App<'static, 'static> { .subcommand(SubCommand::with_name("list") .about("List installed and available components") .arg(Arg::with_name("toolchain") + .help(TOOLCHAIN_ARG_HELP) .long("toolchain") .takes_value(true))) .subcommand(SubCommand::with_name("add") @@ -218,6 +229,7 @@ pub fn cli() -> App<'static, 'static> { .required(true) .multiple(true)) .arg(Arg::with_name("toolchain") + .help(TOOLCHAIN_ARG_HELP) .long("toolchain") .takes_value(true)) .arg(Arg::with_name("target") @@ -229,6 +241,7 @@ pub fn cli() -> App<'static, 'static> { .required(true) .multiple(true)) .arg(Arg::with_name("toolchain") + .help(TOOLCHAIN_ARG_HELP) .long("toolchain") .takes_value(true)) .arg(Arg::with_name("target") @@ -246,6 +259,7 @@ pub fn cli() -> App<'static, 'static> { .about("Set the override toolchain for a directory") .alias("add") .arg(Arg::with_name("toolchain") + .help(TOOLCHAIN_ARG_HELP) .required(true))) .subcommand(SubCommand::with_name("unset") .about("Remove the override toolchain for a directory") @@ -264,6 +278,7 @@ pub fn cli() -> App<'static, 'static> { .after_help(RUN_HELP) .setting(AppSettings::TrailingVarArg) .arg(Arg::with_name("toolchain") + .help(TOOLCHAIN_ARG_HELP) .required(true)) .arg(Arg::with_name("command") .required(true).multiple(true).use_delimiter(false))) @@ -291,6 +306,7 @@ pub fn cli() -> App<'static, 'static> { .arg(Arg::with_name("command") .required(true)) .arg(Arg::with_name("toolchain") + .help(TOOLCHAIN_ARG_HELP) .long("toolchain") .takes_value(true))); }