Skip to content

Commit

Permalink
Consistently give toolchain argument a help text
Browse files Browse the repository at this point in the history
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 <toolchain>

  FLAGS:
      -h, --help    Prints help information

  ARGS:
      <toolchain>    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.
  • Loading branch information
mgeisler committed Jul 23, 2017
1 parent 92d0d1e commit 5611373
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/rustup-cli/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>'.
'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 <toolchain>'.";

pub static DEFAULT_HELP: &'static str =
r"DISCUSSION:
Expand Down Expand Up @@ -262,3 +254,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`";
22 changes: 22 additions & 0 deletions src/rustup-cli/rustup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,18 +132,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")
Expand All @@ -155,6 +158,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")
Expand All @@ -167,33 +171,39 @@ pub fn cli() -> App<'static, 'static> {
.subcommand(SubCommand::with_name("install")
.about("Install or update a given toolchain")
.arg(Arg::with_name("toolchain")
.help(TOOLCHAIN_ARG_HELP)
.required(true)
.multiple(true)))
.subcommand(SubCommand::with_name("uninstall")
.about("Uninstall a toolchain")
.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)))
.subcommand(SubCommand::with_name("update")
.setting(AppSettings::Hidden) // synonym for 'install'
.arg(Arg::with_name("toolchain")
.help(TOOLCHAIN_ARG_HELP)
.required(true)
.multiple(true)))
.subcommand(SubCommand::with_name("add")
.setting(AppSettings::Hidden) // synonym for 'install'
.arg(Arg::with_name("toolchain")
.help(TOOLCHAIN_ARG_HELP)
.required(true)
.multiple(true)))
.subcommand(SubCommand::with_name("remove")
.setting(AppSettings::Hidden) // synonym for 'uninstall'
.arg(Arg::with_name("toolchain")
.help(TOOLCHAIN_ARG_HELP)
.required(true)
.multiple(true))))
.subcommand(SubCommand::with_name("target")
Expand All @@ -204,6 +214,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")
Expand All @@ -212,6 +223,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")
Expand All @@ -220,6 +232,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("install")
Expand All @@ -228,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)))
.subcommand(SubCommand::with_name("uninstall")
Expand All @@ -236,6 +250,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")
Expand All @@ -246,6 +261,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")
Expand All @@ -254,6 +270,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")
Expand All @@ -265,6 +282,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")
Expand All @@ -281,6 +299,7 @@ pub fn cli() -> App<'static, 'static> {
.subcommand(SubCommand::with_name("set")
.about("Set the override toolchain for a directory")
.arg(Arg::with_name("toolchain")
.help(TOOLCHAIN_ARG_HELP)
.required(true)))
.subcommand(SubCommand::with_name("unset")
.about("Remove the override toolchain for a directory")
Expand All @@ -296,6 +315,7 @@ pub fn cli() -> App<'static, 'static> {
.subcommand(SubCommand::with_name("add")
.setting(AppSettings::Hidden) // synonym for 'set'
.arg(Arg::with_name("toolchain")
.help(TOOLCHAIN_ARG_HELP)
.required(true)))
.subcommand(SubCommand::with_name("remove")
.setting(AppSettings::Hidden) // synonym for 'unset'
Expand All @@ -312,6 +332,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)))
Expand Down Expand Up @@ -339,6 +360,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)));
}
Expand Down

0 comments on commit 5611373

Please sign in to comment.