Skip to content

Commit

Permalink
Add --index flag to cargo install
Browse files Browse the repository at this point in the history
  • Loading branch information
kellda committed Jun 8, 2020
1 parent fb0e392 commit 3fbd5ae
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/bin/cargo/commands/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub fn cli() -> App {
.arg(
opt("git", "Git URL to install the specified crate from")
.value_name("URL")
.conflicts_with_all(&["path", "registry"]),
.conflicts_with_all(&["path", "index", "registry"]),
)
.arg(
opt("branch", "Branch to use when installing from git")
Expand All @@ -38,7 +38,7 @@ pub fn cli() -> App {
.arg(
opt("path", "Filesystem path to local crate to install")
.value_name("PATH")
.conflicts_with_all(&["git", "registry"]),
.conflicts_with_all(&["git", "index", "registry"]),
)
.arg(opt(
"list",
Expand All @@ -58,11 +58,17 @@ pub fn cli() -> App {
)
.arg_target_triple("Build for the target triple")
.arg(opt("root", "Directory to install packages into").value_name("DIR"))
.arg(
opt("index", "Registry index to install from")
.value_name("INDEX")
.requires("crate")
.conflicts_with_all(&["git", "path", "registry"]),
)
.arg(
opt("registry", "Registry to use")
.value_name("REGISTRY")
.requires("crate")
.conflicts_with_all(&["git", "path"]),
.conflicts_with_all(&["git", "path", "index"]),
)
.after_help(
"\
Expand Down Expand Up @@ -100,8 +106,6 @@ continuous integration systems.",
}

pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
let registry = args.registry(config)?;

if let Some(path) = args.value_of_path("path", config) {
config.reload_rooted_at(path)?;
} else {
Expand Down Expand Up @@ -143,8 +147,10 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
} else if krates.is_empty() {
from_cwd = true;
SourceId::for_path(config.cwd())?
} else if let Some(registry) = registry {
} else if let Some(registry) = args.registry(config)? {
SourceId::alt_registry(config, &registry)?
} else if let Some(index) = args.value_of("index") {
SourceId::for_registry(&index.into_url()?)?
} else {
SourceId::crates_io(config)?
};
Expand Down

0 comments on commit 3fbd5ae

Please sign in to comment.