File tree 5 files changed +930
-0
lines changed
5 files changed +930
-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
+ . arg_silent_suggestion ( )
18
+ . after_help ( color_print:: cstr!(
19
+ "Run `<cyan,bold>cargo help info</>` for more detailed information.\n "
20
+ ) )
21
+ }
22
+
23
+ pub fn exec ( gctx : & mut GlobalContext , args : & ArgMatches ) -> CliResult {
24
+ let package = args
25
+ . get_one :: < String > ( "package" )
26
+ . map ( String :: as_str)
27
+ . unwrap ( ) ;
28
+ let spec = PackageIdSpec :: parse ( package) . map_err ( |e| {
29
+ anyhow:: format_err!(
30
+ "invalid package id specification `{}`: {}" ,
31
+ package,
32
+ e. to_string( )
33
+ )
34
+ } ) ?;
35
+
36
+ let reg_or_index = args. registry_or_index ( gctx) ?;
37
+ info ( & spec, gctx, reg_or_index) ?;
38
+ Ok ( ( ) )
39
+ }
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