Skip to content

Add a new update-registry subcommand for use by scripts and third-party tools #5961

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/bin/cargo/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub fn builtin() -> Vec<App> {
test::cli(),
uninstall::cli(),
update::cli(),
update_registry::cli(),
verify_project::cli(),
version::cli(),
yank::cli(),
Expand Down Expand Up @@ -64,6 +65,7 @@ pub fn builtin_exec(cmd: &str) -> Option<fn(&mut Config, &ArgMatches) -> CliResu
"test" => test::exec,
"uninstall" => uninstall::exec,
"update" => update::exec,
"update-registry" => update_registry::exec,
"verify-project" => verify_project::exec,
"version" => version::exec,
"yank" => yank::exec,
Expand Down Expand Up @@ -99,6 +101,7 @@ pub mod search;
pub mod test;
pub mod uninstall;
pub mod update;
pub mod update_registry;
pub mod verify_project;
pub mod version;
pub mod yank;
22 changes: 22 additions & 0 deletions src/bin/cargo/commands/update_registry.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use command_prelude::*;

use cargo::core::{Source, SourceId};
use cargo::sources::RegistrySource;

pub fn cli() -> App {
subcommand("update-registry")
.about("Update the local copy of the registry from the network")
.after_help(
"\
Most Cargo commands will update the registry automatically when needed, so you
should not need to invoke this command directly. This command exists primarily
for use by scripts or third-party tools integrating with Cargo.
"
)
}

pub fn exec(config: &mut Config, _args: &ArgMatches) -> CliResult {
let crates_io = SourceId::crates_io(&config)?;
RegistrySource::remote(&crates_io, &config).update()?;
Ok(())
}