File tree 5 files changed +929
-0
lines changed
5 files changed +929
-0
lines changed Original file line number Diff line number Diff line change
1
+ use cargo:: ops:: cargo_info:: info;
2
+ use cargo:: util:: command_prelude:: * ;
3
+ use cargo_util_schemas:: core:: PackageIdSpec ;
4
+
5
+ pub fn cli ( ) -> Command {
6
+ Command :: new ( "info" )
7
+ . about ( "Display information about a package in the registry" )
8
+ . arg (
9
+ Arg :: new ( "package" )
10
+ . required ( true )
11
+ . value_name ( "SPEC" )
12
+ . help_heading ( heading:: PACKAGE_SELECTION )
13
+ . help ( "Package to inspect" ) ,
14
+ )
15
+ . arg_index ( "Registry index URL to search packages in" )
16
+ . arg_registry ( "Registry to search packages in" )
17
+ . after_help ( color_print:: cstr!(
18
+ "Run `<cyan,bold>cargo help info</>` for more detailed information.\n "
19
+ ) )
20
+ }
21
+
22
+ pub fn exec ( gctx : & mut GlobalContext , args : & ArgMatches ) -> CliResult {
23
+ let package = args
24
+ . get_one :: < String > ( "package" )
25
+ . map ( String :: as_str)
26
+ . unwrap ( ) ;
27
+ let spec = PackageIdSpec :: parse ( package) . map_err ( |e| {
28
+ anyhow:: format_err!(
29
+ "invalid package id specification `{}`: {}" ,
30
+ package,
31
+ e. to_string( )
32
+ )
33
+ } ) ?;
34
+
35
+ let reg_or_index = args. registry_or_index ( gctx) ?;
36
+ info ( & spec, gctx, reg_or_index) ?;
37
+ Ok ( ( ) )
38
+ }
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ pub fn builtin() -> Vec<Command> {
14
14
generate_lockfile:: cli( ) ,
15
15
git_checkout:: cli( ) ,
16
16
help:: cli( ) ,
17
+ info:: cli( ) ,
17
18
init:: cli( ) ,
18
19
install:: cli( ) ,
19
20
locate_project:: cli( ) ,
@@ -59,6 +60,7 @@ pub fn builtin_exec(cmd: &str) -> Option<Exec> {
59
60
"generate-lockfile" => generate_lockfile:: exec,
60
61
"git-checkout" => git_checkout:: exec,
61
62
"help" => help:: exec,
63
+ "info" => info:: exec,
62
64
"init" => init:: exec,
63
65
"install" => install:: exec,
64
66
"locate-project" => locate_project:: exec,
@@ -102,6 +104,7 @@ pub mod fix;
102
104
pub mod generate_lockfile;
103
105
pub mod git_checkout;
104
106
pub mod help;
107
+ pub mod info;
105
108
pub mod init;
106
109
pub mod install;
107
110
pub mod locate_project;
You can’t perform that action at this time.
0 commit comments