#[command(version)]
#[command(about = "Query Half-Life servers", long_about = None)]
struct Cli {
+ /// Print output in JSON format
#[arg(short, long)]
json: bool,
+ /// Pretty-print JSON or Rust objects
+ #[arg(short, long)]
+ pretty: bool,
+
addresses: Vec<String>
}
.collect();
if cli.json {
- println!("{}", serde_json::to_string_pretty(&query_results).unwrap());
+ if cli.pretty {
+ println!("{}", serde_json::to_string_pretty(&query_results).unwrap());
+ }
+ else {
+ println!("{}", serde_json::to_string(&query_results).unwrap());
+ }
}
else {
- println!("{:?}", query_results);
+ if cli.pretty {
+ println!("{:#?}", query_results);
+ }
+ else {
+ println!("{:?}", query_results);
+ }
}
}