@@ -13,8 +13,16 @@ pub struct CommandInfo {
13
13
#[ arg( required = true , value_name = "PLATFORM" ) ]
14
14
package : String ,
15
15
16
+ /// The drectory to run `cargo axplat`.
17
+ #[ arg( short = 'C' ) ]
18
+ directory : Option < String > ,
19
+
16
20
/// Path to Cargo.toml
17
- #[ arg( long = "manifest-path" , help_heading = "Manifest Options" ) ]
21
+ #[ arg(
22
+ long = "manifest-path" ,
23
+ value_name = "PATH" ,
24
+ help_heading = "Manifest Options"
25
+ ) ]
18
26
manifest_path : Option < String > ,
19
27
20
28
/// Display the platform name
@@ -83,21 +91,25 @@ impl PlatformInfo {
83
91
} )
84
92
}
85
93
86
- fn from ( package_name : & str , manifest_path : & Option < String > ) -> Result < Self , PlatformInfoErr > {
94
+ fn from ( args : & CommandInfo ) -> Result < Self , PlatformInfoErr > {
87
95
let mut metadata_handler = MetadataCommand :: new ( )
88
96
. features ( CargoOpt :: AllFeatures )
97
+ . verbose ( true )
89
98
. clone ( ) ;
90
99
91
- if let Some ( manifest_path) = manifest_path {
100
+ if let Some ( dir) = & args. directory {
101
+ metadata_handler. current_dir ( dir) ;
102
+ }
103
+ if let Some ( manifest_path) = & args. manifest_path {
92
104
metadata_handler. manifest_path ( manifest_path) ;
93
105
}
94
106
let metadata = metadata_handler. exec ( ) . map_err ( PlatformInfoErr :: Metadata ) ?;
95
107
for p in metadata. packages {
96
- if p. name . as_str ( ) == package_name {
108
+ if p. name . as_str ( ) == args . package {
97
109
return Self :: new ( & p) ;
98
110
}
99
111
}
100
- Err ( PlatformInfoErr :: PackageNotFound ( package_name . into ( ) ) )
112
+ Err ( PlatformInfoErr :: PackageNotFound ( args . package . clone ( ) ) )
101
113
}
102
114
103
115
fn display ( & self , args : & CommandInfo ) {
@@ -140,7 +152,7 @@ fn parse_config(config_path: &str) -> Result<(String, String), PlatformInfoErr>
140
152
}
141
153
142
154
pub fn platform_info ( args : CommandInfo ) {
143
- match PlatformInfo :: from ( & args. package , & args . manifest_path ) {
155
+ match PlatformInfo :: from ( & args) {
144
156
Ok ( info) => {
145
157
if args. plat || args. arch || args. version || args. source || args. config_path {
146
158
info. display ( & args) ;
0 commit comments