Skip to content

Commit d5a80ae

Browse files
committed
Fixes #5
Fixes #7
1 parent 6d37edc commit d5a80ae

File tree

7 files changed

+283
-343
lines changed

7 files changed

+283
-343
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ license = "MIT"
1717

1818
[dependencies]
1919
rust-install = { version = "0.0.4", path = "rust-install" }
20-
clap = { version = "1.4.2", features = ["yaml"] }
20+
clap = "1.4.5"
2121
regex = "0.1.41"
2222
rand = "0.3.11"
2323
hyper = "0.6.14"

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ SUBCOMMANDS:
6969
list-overrides List all overrides.
7070
list-toolchains List all installed toolchains.
7171
override Set the toolchain override.
72+
proxy Proxy a command.
7273
remove-override Remove an override.
7374
remove-toolchain Uninstall a toolchain.
7475
run Run a command.

rust-install/src/errors.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ pub enum Error {
7272
UnsupportedHost,
7373
PermissionDenied,
7474
SettingPermissions(PathBuf),
75+
ToolchainNotInstalled(String),
7576
Custom { id: String, desc: String },
7677
}
7778

@@ -239,6 +240,8 @@ impl Display for Error {
239240
=> write!(f, "permission denied"),
240241
Error::SettingPermissions(ref path)
241242
=> write!(f, "failed to set permissions for: '{}'", path.display()),
243+
Error::ToolchainNotInstalled(ref name)
244+
=> write!(f, "toolchain '{}' is not installed", name),
242245
Error::Custom { id: _, ref desc }
243246
=> write!(f, "{}", desc),
244247
}

src/cli.rs

Lines changed: 240 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,240 @@
1+
2+
use clap::*;
3+
4+
pub fn get() -> App<'static, 'static, 'static, 'static, 'static, 'static> {
5+
App::new("multirust-rs")
6+
.version("0.0.4")
7+
.author("Diggory Blake")
8+
.about("Port of multirust to rust")
9+
.setting(AppSettings::VersionlessSubcommands)
10+
.arg(
11+
Arg::with_name("verbise")
12+
.short("v")
13+
.long("verbose")
14+
.help("Enable verbose output")
15+
)
16+
.subcommand(
17+
SubCommand::with_name("default")
18+
.about("Set the default toolchain.")
19+
.after_help(
20+
r"Sets the default toolchain to the one specified. If the toolchain is
21+
not already installed then it is first installed.
22+
23+
If the toolchain is already installed then it is not reinstalled,
24+
though if installing a custom toolchain with --copy-local,
25+
--link-local, or --installer then the toolchain is always
26+
reinstalled."
27+
)
28+
.arg(Arg::with_name("toolchain").required(true))
29+
.args(install_args())
30+
.arg_group(install_group())
31+
)
32+
.subcommand(
33+
SubCommand::with_name("override")
34+
.about("Set the toolchain override.")
35+
.after_help(
36+
r"Sets the toolchain that will be used when working at or below the
37+
current directory. If the toolchain is not already installed then it
38+
is first installed.
39+
40+
If the toolchain is already installed then it is not reinstalled,
41+
though if installing a custom toolchain with --copy-local,
42+
--link-local, or --installer then the toolchain is always
43+
reinstalled.
44+
45+
To remove an existing override use `multirust remove-override`."
46+
)
47+
.arg(Arg::with_name("toolchain").required(true))
48+
.args(install_args())
49+
.arg_group(install_group())
50+
)
51+
.subcommand(
52+
SubCommand::with_name("update")
53+
.about("Install or update a given toolchain.")
54+
.after_help(
55+
r"With no toolchain specified, the update command updates each of the
56+
stable, beta, and nightly toolchains from the official release
57+
channels."
58+
)
59+
.arg(Arg::with_name("toolchain").required(false))
60+
.args(install_args())
61+
.arg_group(install_group())
62+
)
63+
.subcommand(
64+
SubCommand::with_name("show-override")
65+
.about("Show information about the current override.")
66+
)
67+
.subcommand(
68+
SubCommand::with_name("show-default")
69+
.about("Show information about the current default.")
70+
)
71+
.subcommand(
72+
SubCommand::with_name("list-overrides")
73+
.about("List all overrides.")
74+
)
75+
.subcommand(
76+
SubCommand::with_name("list-toolchains")
77+
.about("List all installed toolchains.")
78+
)
79+
.subcommand(
80+
SubCommand::with_name("remove-override")
81+
.about("Remove an override.")
82+
.after_help(
83+
r"Removes the override for the current directory, or the named
84+
override if one is provided."
85+
)
86+
.arg(Arg::with_name("override").required(false))
87+
)
88+
.subcommand(
89+
SubCommand::with_name("remove-toolchain")
90+
.about("Uninstall a toolchain.")
91+
.after_help(
92+
r"Uninstalls an installed toolchain."
93+
)
94+
.arg(Arg::with_name("toolchain").required(true))
95+
)
96+
.subcommand(
97+
SubCommand::with_name("run")
98+
.setting(AppSettings::TrailingVarArg)
99+
.about("Run a command.")
100+
.after_help(
101+
r"Configures an environment to use the given toolchain and then runs
102+
the specified program. The command may be any program, not just
103+
rustc or cargo. This can be used for testing arbitrary toolchains
104+
without setting an override."
105+
)
106+
.arg(Arg::with_name("toolchain").required(true))
107+
.arg(Arg::with_name("command").required(true).multiple(true))
108+
)
109+
.subcommand(
110+
SubCommand::with_name("proxy")
111+
.setting(AppSettings::TrailingVarArg)
112+
.about("Proxy a command.")
113+
.after_help(
114+
r"Configures an environment to use the correct toolchain for the
115+
current directory, and then runs the specified program. The command
116+
may be any program, not just rustc or cargo."
117+
)
118+
.arg(Arg::with_name("command").required(true).multiple(true))
119+
)
120+
.subcommand(
121+
SubCommand::with_name("delete-data")
122+
.about("Delete all user metadata.")
123+
.after_help(
124+
r"Rremoves all installed toolchains, overrides, and aliases for the
125+
current user.
126+
127+
Prompts for confirmation, unless disabled.
128+
129+
Does not uninstall multirust."
130+
)
131+
.arg(Arg::with_name("no-prompt").short("y").help("Disable confirmation prompt."))
132+
)
133+
.subcommand(
134+
SubCommand::with_name("upgrade-data")
135+
.about("Upgrade the ~/.multirust directory.")
136+
.after_help(
137+
r"Upgrades the ~/.multirust directory from previous versions."
138+
)
139+
)
140+
.subcommand(
141+
SubCommand::with_name("install")
142+
.about("Installs multirust.")
143+
.after_help(
144+
r"Installs multirust for the current user."
145+
)
146+
.arg(Arg::with_name("add-to-path").short("a").long("add-to-path").help("Modifies .profile or the registry"))
147+
.arg(Arg::with_name("move").short("m").long("move").help("Move self instead of copying"))
148+
)
149+
.subcommand(
150+
SubCommand::with_name("uninstall")
151+
.about("Uninstalls multirust.")
152+
)
153+
.subcommand(
154+
SubCommand::with_name("doc")
155+
.about("Open the documentation for the current toolchain.")
156+
.after_help(
157+
r"Opens the documentation for the currently active toolchain with the
158+
default browser.
159+
160+
By default, it opens the API documentation for the standard library."
161+
)
162+
.arg(Arg::with_name("all").long("all").help(r"
163+
Opens the documentation overview page, which
164+
gives access to all the installed documentation.
165+
"))
166+
)
167+
.subcommand(
168+
SubCommand::with_name("which")
169+
.about("Report location of the currently active Rust tool.")
170+
.arg(Arg::with_name("binary").required(true))
171+
)
172+
.subcommand(
173+
SubCommand::with_name("ctl")
174+
.subcommand(
175+
SubCommand::with_name("home")
176+
)
177+
.subcommand(
178+
SubCommand::with_name("override-toolchain")
179+
)
180+
.subcommand(
181+
SubCommand::with_name("default-toolchain")
182+
)
183+
.subcommand(
184+
SubCommand::with_name("toolchain-sysroot")
185+
.arg(Arg::with_name("toolchain").required(true))
186+
)
187+
)
188+
}
189+
190+
fn install_args() -> Vec<Arg<'static, 'static, 'static, 'static, 'static, 'static>> {
191+
vec![
192+
Arg::with_name("copy-local")
193+
.long("copy-local")
194+
.help(r"
195+
Install by copying a local toolchain. This will
196+
copy the toolchain from a local directory to a
197+
directory in multirust's home.
198+
")
199+
.takes_value(true)
200+
.value_name("toolchain-path")
201+
.number_of_values(1),
202+
Arg::with_name("link-local")
203+
.long("link-local")
204+
.help(r"
205+
Install by linking to a local toolchain. This
206+
will create a soft link to the local toolchain
207+
in multirust's home.
208+
")
209+
.takes_value(true)
210+
.value_name("toolchain-path")
211+
.number_of_values(1),
212+
Arg::with_name("installer")
213+
.long("installer")
214+
.help(r"
215+
Allows arbitrary builds of rust to be installed
216+
from a custom-built installer, either from the
217+
local filesystem or the network. Custom
218+
installers are neither checksum nor
219+
signature-verified.
220+
221+
If multiple installers are specified then they
222+
are all installed to the same location. This can
223+
make installing cargo easier since otherwise it
224+
would need to be combined with rustc into a
225+
single installer through the rust-packaging
226+
project.
227+
")
228+
.takes_value(true)
229+
.value_name("toolchain-path")
230+
.min_values(1),
231+
]
232+
}
233+
234+
fn install_group() -> ArgGroup<'static, 'static> {
235+
ArgGroup::with_name("toolchain-source")
236+
.add("copy-local")
237+
.add("link-local")
238+
.add("installer")
239+
.requires("toolchain")
240+
}

0 commit comments

Comments
 (0)