Skip to content

Commit

Permalink
Upgrade to clap 2.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
brson committed Mar 20, 2016
1 parent d52b3d3 commit c34904b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ license = "MIT OR Apache-2.0"
[dependencies]
multirust-dist = { version = "0.0.5", path = "src/multirust-dist" }
multirust-utils = { version = "0.0.5", path = "src/multirust-utils" }
clap = "1.4.5"
clap = "2.2.1"
regex = "0.1.41"
openssl = "0.7.2"
hyper = "0.7.0"
Expand Down
29 changes: 15 additions & 14 deletions src/multirust-cli/cli.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

use clap::*;

pub fn get() -> App<'static, 'static, 'static, 'static, 'static, 'static> {
pub fn get() -> App<'static, 'static> {
App::new("multirust-rs")
.version("0.0.5")
.author("Diggory Blake")
Expand All @@ -28,8 +28,8 @@ reinstalled.
"
)
.arg(Arg::with_name("toolchain").required(true))
.args(install_args())
.arg_group(install_group())
.args(&install_args())
.group(install_group())
)
.subcommand(
SubCommand::with_name("override")
Expand All @@ -48,8 +48,8 @@ To remove an existing override use `multirust remove-override`.
"
)
.arg(Arg::with_name("toolchain").required(true))
.args(install_args())
.arg_group(install_group())
.args(&install_args())
.group(install_group())
)
.subcommand(
SubCommand::with_name("update")
Expand All @@ -61,8 +61,8 @@ channels, plus any other installed toolchains.
"
)
.arg(Arg::with_name("toolchain").required(false))
.args(install_args())
.arg_group(install_group())
.args(&install_args())
.group(install_group())
)
.subcommand(
SubCommand::with_name("show-override")
Expand Down Expand Up @@ -204,7 +204,7 @@ open specific pieces of documentation.
)
.arg(Arg::with_name("book").long("book").help("The Rust Programming Language book"))
.arg(Arg::with_name("std").long("std").help("Standard library API documentation"))
.arg_group(ArgGroup::with_name("page").add_all(&["book", "std"]))
.group(ArgGroup::with_name("page").args(&["book", "std"]))
)
.subcommand(
SubCommand::with_name("which")
Expand All @@ -213,7 +213,7 @@ open specific pieces of documentation.
)
}

fn install_args() -> Vec<Arg<'static, 'static, 'static, 'static, 'static, 'static>> {
fn install_args() -> Vec<Arg<'static, 'static>> {
vec![
Arg::with_name("copy-local")
.long("copy-local")
Expand Down Expand Up @@ -253,14 +253,15 @@ fn install_args() -> Vec<Arg<'static, 'static, 'static, 'static, 'static, 'stati
")
.takes_value(true)
.value_name("toolchain-path")
.min_values(1),
.number_of_values(1)
.multiple(true),
]
}

fn install_group() -> ArgGroup<'static, 'static> {
fn install_group() -> ArgGroup<'static> {
ArgGroup::with_name("toolchain-source")
.add("copy-local")
.add("link-local")
.add("installer")
.arg("copy-local")
.arg("link-local")
.arg("installer")
.requires("toolchain")
}
6 changes: 3 additions & 3 deletions src/multirust-cli/multirust_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ fn maybe_setup_winjob(m: &ArgMatches) {
fn run(cfg: &Cfg, m: &ArgMatches) -> Result<()> {
let toolchain = try!(get_toolchain(cfg, m, false));
let args = m.values_of("command").unwrap();

let args: Vec<_> = args.collect();
let cmd = try!(toolchain.create_command(args[0]));
run_inner(cmd, &args)
}

fn proxy(cfg: &Cfg, m: &ArgMatches) -> Result<()> {
let args = m.values_of("command").unwrap();

let args: Vec<_> = args.collect();
let cmd = try!(cfg.create_command_for_dir(&try!(utils::current_dir()), args[0]));
run_inner(cmd, &args)
}
Expand Down Expand Up @@ -177,7 +177,7 @@ fn override_(cfg: &Cfg, m: &ArgMatches) -> Result<()> {
fn common_install_args(toolchain: &Toolchain, m: &ArgMatches) -> Result<bool> {

if let Some(installers) = m.values_of("installer") {
let is: Vec<_> = installers.iter().map(|i| i.as_ref()).collect();
let is: Vec<_> = installers.map(|i| i.as_ref()).collect();
try!(toolchain.install_from_installers(&*is));
} else if let Some(path) = m.value_of("copy-local") {
try!(toolchain.install_from_dir(Path::new(path), false));
Expand Down
2 changes: 1 addition & 1 deletion src/multirust-cli/setup_mode.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::env;
use self_update;
use multirust::Result;
use clap::*;
use clap::{App, Arg};

pub fn main() -> Result<()> {
let args: Vec<_> = env::args().collect();
Expand Down

0 comments on commit c34904b

Please sign in to comment.