blob: 81a5067deef9b427704a7b5edf374c5f7cf9d59b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
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
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();
let resp = reqwest::get(&args.url)
.await?
.bytes().await?;
let proto = FeedMessage::parse_from_bytes(&resp[..])?;
match args.json {
true =>
println!("{}", protobuf_json_mapping::print_to_string(&proto)?),
false =>
println!("{}", protobuf::text_format::print_to_string_pretty(&proto))
}
Ok(())
}
|