-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7dcf764
commit f582df0
Showing
5 changed files
with
929 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use cargo::ops::cargo_info::info; | ||
use cargo::util::command_prelude::*; | ||
use cargo_util_schemas::core::PackageIdSpec; | ||
|
||
pub fn cli() -> Command { | ||
Command::new("info") | ||
.about("Display information about a package in the registry") | ||
.arg( | ||
Arg::new("package") | ||
.required(true) | ||
.value_name("SPEC") | ||
.help_heading(heading::PACKAGE_SELECTION) | ||
.help("Package to inspect"), | ||
) | ||
.arg_index("Registry index URL to search packages in") | ||
.arg_registry("Registry to search packages in") | ||
.after_help(color_print::cstr!( | ||
"Run `<cyan,bold>cargo help info</>` for more detailed information.\n" | ||
)) | ||
} | ||
|
||
pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult { | ||
let package = args | ||
.get_one::<String>("package") | ||
.map(String::as_str) | ||
.unwrap(); | ||
let spec = PackageIdSpec::parse(package).map_err(|e| { | ||
anyhow::format_err!( | ||
"invalid package id specification `{}`: {}", | ||
package, | ||
e.to_string() | ||
) | ||
})?; | ||
|
||
let reg_or_index = args.registry_or_index(gctx)?; | ||
info(&spec, gctx, reg_or_index)?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.