Skip to content

Commit

Permalink
Somewhat prepare for trycmd ui testing
Browse files Browse the repository at this point in the history
  • Loading branch information
zohnannor committed Feb 11, 2023
1 parent 9fdca07 commit 4a62a92
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 22 deletions.
99 changes: 94 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ no-self-update = []
anyhow = "1.0.69"
cfg-if = "1.0"
chrono = "0.4"
clap = "3"
clap = {version = "3", features = ["wrap_help"]}
clap_complete = "3"
download = {path = "download", default-features = false}
effective-limits = "0.5.3"
Expand Down
24 changes: 12 additions & 12 deletions src/cli/rustup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,19 @@ pub(crate) fn cli() -> Command<'static> {
.after_help(RUSTUP_HELP)
.global_setting(AppSettings::DeriveDisplayOrder)
.arg_required_else_help(true)
.next_help_heading("FLAGS")
.arg(
verbose_arg("Enable verbose output"),
)
.help_template(
"\
{name} {version}
{about}
USAGE:
{usage}
{all-args}",
)
.arg(
Arg::new("quiet")
.conflicts_with("verbose")
Expand All @@ -216,7 +225,6 @@ pub(crate) fn cli() -> Command<'static> {
.long("quiet")
.action(ArgAction::SetTrue),
)
.next_help_heading("ARGS")
.arg(
Arg::new("+toolchain")
.help("release channel (e.g. +stable) or custom toolchain to set override")
Expand Down Expand Up @@ -273,7 +281,6 @@ pub(crate) fn cli() -> Command<'static> {
.value_parser(PossibleValuesParser::new(Profile::names()))
.takes_value(true),
)
.next_help_heading("FLAGS")
.arg(
Arg::new("no-self-update")
.help("Don't perform self-update when running the `rustup install` command")
Expand Down Expand Up @@ -316,7 +323,6 @@ pub(crate) fn cli() -> Command<'static> {
.takes_value(true)
.multiple_values(true),
)
.next_help_heading("FLAGS")
.arg(
Arg::new("no-self-update")
.help("Don't perform self update when running the `rustup update` command")
Expand Down Expand Up @@ -398,7 +404,6 @@ pub(crate) fn cli() -> Command<'static> {
.multiple_occurrences(true)
.use_value_delimiter(true),
)
.next_help_heading("FLAGS")
.arg(
Arg::new("no-self-update")
.help(
Expand Down Expand Up @@ -470,7 +475,6 @@ pub(crate) fn cli() -> Command<'static> {
.long("toolchain")
.takes_value(true),
)
.next_help_heading("FLAGS")
.arg(
Arg::new("installed")
.long("installed")
Expand Down Expand Up @@ -532,7 +536,6 @@ pub(crate) fn cli() -> Command<'static> {
.long("toolchain")
.takes_value(true),
)
.next_help_heading("FLAGS")
.arg(
Arg::new("installed")
.long("installed")
Expand Down Expand Up @@ -612,7 +615,6 @@ pub(crate) fn cli() -> Command<'static> {
.takes_value(true)
.help("Path to the directory"),
)
.next_help_heading("FLAGS")
.arg(
Arg::new("nonexistent")
.long("nonexistent")
Expand All @@ -639,7 +641,6 @@ pub(crate) fn cli() -> Command<'static> {
.multiple_values(true)
.use_value_delimiter(false),
)
.next_help_heading("FLAGS")
.arg(
Arg::new("install")
.help("Install the requested toolchain if needed")
Expand Down Expand Up @@ -684,7 +685,6 @@ pub(crate) fn cli() -> Command<'static> {
.collect::<Vec<_>>(),
),
)
.next_help_heading("FLAGS")
.args(
&DOCS_DATA
.iter()
Expand Down Expand Up @@ -1520,7 +1520,7 @@ fn override_remove(cfg: &Cfg, m: &ArgMatches) -> Result<utils::ExitCode> {
info!("override toolchain for '{}' removed", path);
} else {
info!("no override toolchain for '{}'", path);
if !m.contains_id("path") && !m.get_flag("nonexistent") {
if !m.get_one::<String>("path").is_some() && !m.get_flag("nonexistent") {
info!(
"you may use `--path <path>` option to remove override toolchain \
for a specific path"
Expand Down Expand Up @@ -1582,7 +1582,7 @@ fn doc(cfg: &Cfg, m: &ArgMatches) -> Result<utils::ExitCode> {
let doc_url = if let Some(topic) = m.get_one::<String>("topic") {
topical_path = topical_doc::local_path(&toolchain.doc_path("").unwrap(), topic)?;
topical_path.to_str().unwrap()
} else if let Some((_, _, path)) = DOCS_DATA.iter().find(|(name, _, _)| m.contains_id(name)) {
} else if let Some((_, _, path)) = DOCS_DATA.iter().find(|(name, _, _)| m.get_flag(name)) {
path
} else {
"index.html"
Expand Down
15 changes: 11 additions & 4 deletions src/cli/setup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,16 @@ pub fn main() -> Result<utils::ExitCode> {
.version(common::version())
.about("The installer for rustup")
.setting(AppSettings::DeriveDisplayOrder)
.next_help_heading("FLAGS")
.help_template(
"\
{name} {version}
{about}
USAGE:
{usage}
{all-args}",
)
.arg(
Arg::new("verbose")
.short('v')
Expand All @@ -49,7 +58,6 @@ pub fn main() -> Result<utils::ExitCode> {
.help("Disable confirmation prompt.")
.action(ArgAction::SetTrue),
)
.next_help_heading("OPTIONS")
.arg(
Arg::new("default-host")
.long("default-host")
Expand Down Expand Up @@ -87,7 +95,6 @@ pub fn main() -> Result<utils::ExitCode> {
.multiple_values(true)
.use_value_delimiter(true),
)
.next_help_heading("FLAGS")
.arg(
Arg::new("no-update-default-toolchain")
.long("no-update-default-toolchain")
Expand All @@ -107,7 +114,7 @@ pub fn main() -> Result<utils::ExitCode> {
if e.kind() == clap::ErrorKind::DisplayHelp
|| e.kind() == clap::ErrorKind::DisplayVersion =>
{
writeln!(process().stdout().lock(), "{}", e)?;
writeln!(process().stdout().lock(), "{e}")?;
return Ok(utils::ExitCode(0));
}
Err(e) => return Err(e.into()),
Expand Down

0 comments on commit 4a62a92

Please sign in to comment.