diff options
author | stuebinm | 2022-11-05 02:51:09 +0100 |
---|---|---|
committer | stuebinm | 2022-11-05 02:51:09 +0100 |
commit | f3daba4974b1e543e14e7a626bf2d0bcdcd4190f (patch) | |
tree | bfc3e330dc67c65d665ecf8254c5e52643c10e9d /src/main.rs |
intial commit: simple printing of feeds
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..fd02f82 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,28 @@ + +mod protos; +use protos::protos::gtfs_realtime::FeedMessage; + +use protobuf::Message; +use clap::Parser; + +#[derive(Parser, Debug)] +#[command(author, version, about, long_about = None)] +struct Args { + /// uri of the GTFS RT feed to fetch & display + #[arg(long)] + url: String, +} + +#[tokio::main] +async fn main() -> Result<(), Box<dyn std::error::Error>> { + let args = Args::parse(); + let resp = reqwest::get(&args.url) + .await? + .bytes().await?; + + let proto = FeedMessage::parse_from_bytes(&resp[..])?; + + println!("{}", protobuf::text_format::print_to_string_pretty(&proto)); + Ok(()) +} + |