diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..ee6bea6 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,18 @@ +# editorconfig.org +root = true + +[*] +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +# Use tabs in JavaScript and JSON. +[**.{js, json}] +indent_style = tab +indent_size = 4 + +# Use spaces in YAML. +[**.{yml,yaml}] +indent_style = spaces +indent_size = 2 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..808662f --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +.DS_Store +Thumbs.db + +.nvm-version +node_modules +npm-debug.log +pnpm-debug.log + +package-lock.json +shrinkwrap.yaml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..fca8a26 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,5 @@ +sudo: false +language: node_js +node_js: + - 'stable' + - '8' diff --git a/cli.js b/cli.js new file mode 100755 index 0000000..6a3f067 --- /dev/null +++ b/cli.js @@ -0,0 +1,39 @@ +#!/usr/bin/env node +'use strict' + +const mri = require('mri') + +const pkg = require('./package.json') + +const argv = mri(process.argv.slice(2), { + boolean: [ + 'help', 'h', + 'version', 'v', + 'json', 'j' + ] +}) + +if (argv.help || argv.h) { + process.stdout.write(` +Usage: + cat gtfs-rt-feed.pbf | print-gtfs-rt +Options: + --json -j Output JSON instead of a pretty represenation. +Examples: + curl 'https://example.org/gtfs-rt.pbf' | print-gtfs-rt +\n`) + process.exit(0) +} + +if (argv.version || argv.v) { + process.stdout.write(`print-gtfs-rt v${pkg.version}\n`) + process.exit(0) +} + +const showError = (err) => { + if (process.env.NODE_ENV === 'dev') console.error(err) + else console.error(err.message || (err + '')) + process.exit(1) +} + +// todo diff --git a/license.md b/license.md new file mode 100644 index 0000000..4d4e73c --- /dev/null +++ b/license.md @@ -0,0 +1,5 @@ +Copyright (c) 2018, Jannis R + +Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/package.json b/package.json new file mode 100644 index 0000000..6780bb7 --- /dev/null +++ b/package.json @@ -0,0 +1,35 @@ +{ + "name": "print-gtfs-rt-cli", + "description": "Read a GTFS Realtime feed from stdin, print human-readable or as JSON.", + "version": "1.0.0", + "files": [ + "cli.js" + ], + "bin": { + "print-gtfs-rt": "./cli.js" + }, + "keywords": [ + "gtfs", + "general transit feed specification", + "gtfs-rt", + "realtime", + "feed", + "command line", + "cli" + ], + "author": "Jannis R ", + "homepage": "https://github.com/derhuerst/fetch-gtfs-rt-cli", + "repository": "derhuerst/fetch-gtfs-rt-cli", + "bugs": "https://github.com/derhuerst/fetch-gtfs-rt-cli/issues", + "license": "ISC", + "engines": { + "node": ">=8" + }, + "dependencies": { + "mri": "^1.1.1" + }, + "scripts": { + "test": "echo todo; exit 1", + "prepublishOnly": "npm test" + } +} diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..a9a520a --- /dev/null +++ b/readme.md @@ -0,0 +1,35 @@ +# print-gtfs-rt-cli + +**Read a [GTFS Realtime](https://developers.google.com/transit/gtfs-realtime/) feed from stdin, print human-readable or as JSON.** + +[![npm version](https://img.shields.io/npm/v/print-gtfs-rt-cli.svg)](https://www.npmjs.com/package/print-gtfs-rt-cli) +[![build status](https://api.travis-ci.org/derhuerst/print-gtfs-rt-cli.svg?branch=master)](https://travis-ci.org/derhuerst/print-gtfs-rt-cli) +![ISC-licensed](https://img.shields.io/github/license/derhuerst/print-gtfs-rt-cli.svg) +[![chat with me on Gitter](https://img.shields.io/badge/chat%20with%20me-on%20gitter-512e92.svg)](https://gitter.im/derhuerst) +[![support me on Patreon](https://img.shields.io/badge/support%20me-on%20patreon-fa7664.svg)](https://patreon.com/derhuerst) + + +## Installing + +```shell +npm install -g print-gtfs-rt-cli +``` + +Or use [`npx`](https://npmjs.com/package/npx). ✨ + + +## Usage + +``` +Usage: + cat gtfs-rt-feed.pbf | print-gtfs-rt +Options: + --json -j Output JSON instead of a pretty represenation. +Examples: + curl 'https://example.org/gtfs-rt.pbf' | print-gtfs-rt +``` + + +## Contributing + +If you have a question or have difficulties using `print-gtfs-rt-cli`, please double-check your code and setup first. If you think you have found a bug or want to propose a feature, refer to [the issues page](https://github.com/derhuerst/print-gtfs-rt-cli/issues).