From 037ec595a3926d7af5ae5816d4e791e7130c3696 Mon Sep 17 00:00:00 2001 From: stuebinm Date: Thu, 1 Dec 2022 00:50:46 +0100 Subject: readme & stuff --- Cargo.lock | 3 +++ Cargo.toml | 2 +- Readme.md | 35 +++++++++++++++++++++++++++++++++++ src/main.rs | 10 ++++++++-- 4 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 Readme.md diff --git a/Cargo.lock b/Cargo.lock index 5874327..7b0fb33 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -538,6 +538,9 @@ name = "owo-colors" version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" +dependencies = [ + "supports-color", +] [[package]] name = "parking_lot" diff --git a/Cargo.toml b/Cargo.toml index 3d7507c..8e44e62 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,4 +17,4 @@ reqwest = { version = "0.11", features = ["json", "rustls-tls"], default-feature tokio = { version = "1", features = ["full"] } clap = { version = "4", features = ["derive"] } miette = { version = "5", features = ["fancy"] } -owo-colors = "3.5" +owo-colors = { version = "3.5", features = ["supports-color"] } diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..a34e921 --- /dev/null +++ b/Readme.md @@ -0,0 +1,35 @@ +# human-readable gtfs realtime feeds + +a tool to answer to the question "how to check that the gtfs realtime feed says +what it's supposed to if for some unfortunate reason you can't read binary?". + +At 188 crates, it might be suspected that it gives a *slightly* over-engineered +answer. + +~~~ +Usage: showrt [OPTIONS] + +Arguments: + uri of the GTFS RT feed to fetch & display + +Options: + --json emit the feed as json + -i, --ignore-nonfatal ignore things that look wrong as long as possible + --no-colors don't do terminal colours + -h, --help Print help information + -V, --version Print version information +~~~ + +### Features: + - fetch feeds from some url + - display feeds in protobuf pseudo-format, optionally with fancy colours + - dump the entire feed as json to process it with `jq` & friends + - error messages with entirely too many arrows in them + +### Still Todo: + - open local files (why do people even have these?) + - play nice with (input-)pipes + - optionally convert all dates into something more human-friendly than seconds + since the unix epoch + - optionally collapse translations that contain only one language in the output + diff --git a/src/main.rs b/src/main.rs index 59e7e51..315d093 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,8 +17,12 @@ struct Args { /// emit the feed as json #[arg(long)] json: bool, + /// ignore things that look wrong as long as possible #[arg(long="ignore-nonfatal", short='i')] - ignore_nonfatal: bool + ignore_nonfatal: bool, + /// don't do terminal colours + #[arg(long="no-colors")] + no_colors: bool } @@ -52,7 +56,9 @@ async fn main() -> miette::Result<()> { match args.json { true => println!("{}", protobuf_json_mapping::print_to_string(&proto).into_diagnostic()?), - false => + false if args.no_colors => + println!("{}", protobuf::text_format::print_to_string_pretty(&proto)), + false => println!("{}", fancy::print_to_string_fancy(&proto)) } -- cgit v1.2.3