@@ -13,8 +13,16 @@ pub struct CommandInfo {
1313 #[ arg( required = true , value_name = "PLATFORM" ) ]
1414 package : String ,
1515
16+ /// The drectory to run `cargo axplat`.
17+ #[ arg( short = 'C' ) ]
18+ directory : Option < String > ,
19+
1620 /// 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+ ) ]
1826 manifest_path : Option < String > ,
1927
2028 /// Display the platform name
@@ -83,21 +91,25 @@ impl PlatformInfo {
8391 } )
8492 }
8593
86- fn from ( package_name : & str , manifest_path : & Option < String > ) -> Result < Self , PlatformInfoErr > {
94+ fn from ( args : & CommandInfo ) -> Result < Self , PlatformInfoErr > {
8795 let mut metadata_handler = MetadataCommand :: new ( )
8896 . features ( CargoOpt :: AllFeatures )
97+ . verbose ( true )
8998 . clone ( ) ;
9099
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 {
92104 metadata_handler. manifest_path ( manifest_path) ;
93105 }
94106 let metadata = metadata_handler. exec ( ) . map_err ( PlatformInfoErr :: Metadata ) ?;
95107 for p in metadata. packages {
96- if p. name . as_str ( ) == package_name {
108+ if p. name . as_str ( ) == args . package {
97109 return Self :: new ( & p) ;
98110 }
99111 }
100- Err ( PlatformInfoErr :: PackageNotFound ( package_name . into ( ) ) )
112+ Err ( PlatformInfoErr :: PackageNotFound ( args . package . clone ( ) ) )
101113 }
102114
103115 fn display ( & self , args : & CommandInfo ) {
@@ -140,7 +152,7 @@ fn parse_config(config_path: &str) -> Result<(String, String), PlatformInfoErr>
140152}
141153
142154pub fn platform_info ( args : CommandInfo ) {
143- match PlatformInfo :: from ( & args. package , & args . manifest_path ) {
155+ match PlatformInfo :: from ( & args) {
144156 Ok ( info) => {
145157 if args. plat || args. arch || args. version || args. source || args. config_path {
146158 info. display ( & args) ;
0 commit comments