summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs
index fd02f82..81a5067 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -9,10 +9,13 @@ use clap::Parser;
#[command(author, version, about, long_about = None)]
struct Args {
/// uri of the GTFS RT feed to fetch & display
- #[arg(long)]
url: String,
+ /// emit the feed as json
+ #[arg(long)]
+ json: bool
}
+
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let args = Args::parse();
@@ -21,8 +24,13 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.bytes().await?;
let proto = FeedMessage::parse_from_bytes(&resp[..])?;
-
- println!("{}", protobuf::text_format::print_to_string_pretty(&proto));
+
+ match args.json {
+ true =>
+ println!("{}", protobuf_json_mapping::print_to_string(&proto)?),
+ false =>
+ println!("{}", protobuf::text_format::print_to_string_pretty(&proto))
+ }
Ok(())
}