-
Notifications
You must be signed in to change notification settings - Fork 34
/
setup_mode.rs
57 lines (51 loc) · 1.79 KB
/
setup_mode.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
use clap::{App, AppSettings, Arg};
use common;
use errors::*;
use self_update::{self, InstallOpts};
use std::env;
pub fn main() -> Result<()> {
let args: Vec<_> = env::args().collect();
let arg1 = args.get(1).map(|a| &**a);
// Secret command used during self-update. Not for users.
if arg1 == Some("--self-replace") {
return self_update::self_replace();
}
// XXX: If you change anything here, please make the same changes in elan-init.sh
let cli = App::new("elan-init")
.version(common::version())
.about("The installer for elan")
.setting(AppSettings::DeriveDisplayOrder)
.arg(
Arg::with_name("verbose")
.short("v")
.long("verbose")
.help("Enable verbose output"),
)
.arg(
Arg::with_name("no-prompt")
.short("y")
.help("Disable confirmation prompt."),
)
.arg(
Arg::with_name("default-toolchain")
.long("default-toolchain")
.takes_value(true)
.help("Choose a default toolchain"),
)
.arg(
Arg::with_name("no-modify-path")
.long("no-modify-path")
.help("Don't configure the PATH environment variable"),
);
let matches = cli.get_matches();
let no_prompt = matches.is_present("no-prompt");
let verbose = matches.is_present("verbose");
let default_toolchain = matches.value_of("default-toolchain").unwrap_or("stable");
let no_modify_path = matches.is_present("no-modify-path");
let opts = InstallOpts {
default_toolchain: default_toolchain.to_owned(),
no_modify_path: no_modify_path,
};
self_update::install(no_prompt, verbose, opts)?;
Ok(())
}