1+ use std:: collections:: HashMap ;
12use std:: env;
23use std:: fs;
3- use std:: collections:: HashMap ;
44
55use anyhow:: { Context , Result } ;
66
@@ -27,18 +27,22 @@ fn real_main() -> Result<()> {
2727
2828 // Load OpenAPI (for default base URL)
2929 let openapi_text = if let Some ( path) = openapi_file. as_deref ( ) {
30- fs:: read_to_string ( path) . with_context ( || format ! ( "Failed to read openapi file: {}" , path) ) ?
30+ fs:: read_to_string ( path)
31+ . with_context ( || format ! ( "Failed to read openapi file: {}" , path) ) ?
3132 } else {
3233 EMBEDDED_OPENAPI . to_string ( )
3334 } ;
3435 let openapi = rclib:: parse_openapi ( & openapi_text) . context ( "OpenAPI parsing failed" ) ?;
35- let default_base_url = openapi. servers . first ( ) . map ( |s| s. url . clone ( ) ) . unwrap_or_else ( || {
36- "https://dummyjson.com" . to_string ( )
37- } ) ;
36+ let default_base_url = openapi
37+ . servers
38+ . first ( )
39+ . map ( |s| s. url . clone ( ) )
40+ . unwrap_or_else ( || "https://dummyjson.com" . to_string ( ) ) ;
3841
3942 // Load mapping used to build the dynamic command tree
4043 let mapping_yaml = if let Some ( path) = mapping_file. as_deref ( ) {
41- fs:: read_to_string ( path) . with_context ( || format ! ( "Failed to read mapping file: {}" , path) ) ?
44+ fs:: read_to_string ( path)
45+ . with_context ( || format ! ( "Failed to read mapping file: {}" , path) ) ?
4246 } else {
4347 EMBEDDED_MAPPING . to_string ( )
4448 } ;
@@ -66,7 +70,13 @@ fn real_main() -> Result<()> {
6670
6771 // Delegate command driving to rclib
6872 let user_agent = format ! ( "{}/{}" , APP_NAME , env!( "CARGO_PKG_VERSION" ) ) ;
69- let exit_code = rclib:: cli:: drive_command ( & mapping_root, & default_base_url, & matches, & reg, & user_agent) ?;
73+ let exit_code = rclib:: cli:: drive_command (
74+ & mapping_root,
75+ & default_base_url,
76+ & matches,
77+ & reg,
78+ & user_agent,
79+ ) ?;
7080 std:: process:: exit ( exit_code) ;
7181}
7282
@@ -77,8 +87,14 @@ fn handle_export_users(
7787 json_output : bool ,
7888) -> Result < ( ) > {
7989 let format = vars. get ( "format" ) . map ( |s| s. as_str ( ) ) . unwrap_or ( "json" ) ;
80- let output_file = vars. get ( "output_file" ) . map ( |s| s. as_str ( ) ) . unwrap_or ( "users_export.json" ) ;
81- let include_sensitive = vars. get ( "include_sensitive" ) . map ( |s| s == "true" ) . unwrap_or ( false ) ;
90+ let output_file = vars
91+ . get ( "output_file" )
92+ . map ( |s| s. as_str ( ) )
93+ . unwrap_or ( "users_export.json" ) ;
94+ let include_sensitive = vars
95+ . get ( "include_sensitive" )
96+ . map ( |s| s == "true" )
97+ . unwrap_or ( false ) ;
8298 let limit = vars. get ( "limit" ) . map ( |s| s. as_str ( ) ) . unwrap_or ( "100" ) ;
8399 let skip = vars. get ( "skip" ) . map ( |s| s. as_str ( ) ) . unwrap_or ( "0" ) ;
84100
@@ -101,10 +117,20 @@ fn handle_export_users(
101117 println ! ( "User Export Operation" ) ;
102118 println ! ( "Format: {}" , format) ;
103119 println ! ( "Output: {}" , output_file) ;
104- println ! ( "Sensitive data: {}" , if include_sensitive { "included" } else { "excluded" } ) ;
120+ println ! (
121+ "Sensitive data: {}" ,
122+ if include_sensitive {
123+ "included"
124+ } else {
125+ "excluded"
126+ }
127+ ) ;
105128 println ! ( "Records: {} (starting from {})" , limit, skip) ;
106129 println ! ( "API Base: {}" , base_url) ;
107- println ! ( "\n Export would fetch from: {}/users?limit={}&skip={}" , base_url, limit, skip) ;
130+ println ! (
131+ "\n Export would fetch from: {}/users?limit={}&skip={}" ,
132+ base_url, limit, skip
133+ ) ;
108134 println ! ( " Would save to: {}" , output_file) ;
109135 }
110136
@@ -117,10 +143,16 @@ fn handle_product_analytics(
117143 base_url : & str ,
118144 json_output : bool ,
119145) -> Result < ( ) > {
120- let report_type = vars. get ( "report_type" ) . map ( |s| s. as_str ( ) ) . unwrap_or ( "summary" ) ;
146+ let report_type = vars
147+ . get ( "report_type" )
148+ . map ( |s| s. as_str ( ) )
149+ . unwrap_or ( "summary" ) ;
121150 let category_filter = vars. get ( "category_filter" ) . map ( |s| s. as_str ( ) ) ;
122151 let price_range = vars. get ( "price_range" ) . map ( |s| s. as_str ( ) ) ;
123- let output_format = vars. get ( "output_format" ) . map ( |s| s. as_str ( ) ) . unwrap_or ( "table" ) ;
152+ let output_format = vars
153+ . get ( "output_format" )
154+ . map ( |s| s. as_str ( ) )
155+ . unwrap_or ( "table" ) ;
124156
125157 if json_output {
126158 let response = serde_json:: json!( {
0 commit comments