CLI tool to obtain schedule info from the dutch railway services
Project description
nstimes
Find your next train home while you are in CLI. I used the Dutch Railway Services (Nederlandse Spoorwegen) API to make myself this tool.
Usage:
$ nstimes [OPTIONS] COMMAND [ARGS]...
Options:
--version
: Print version info--install-completion
: Install completion for the current shell.--show-completion
: Show completion for the current shell, to copy it or customize the installation.--help
: Show this message and exit.
Commands:
journey
: Provide train type, platform and departure...update-stations-json
: Generate stations lookup
nstimes journey
Provide train type, platform and departure times of an A -> B journey
Usage:
$ nstimes journey [OPTIONS]
Options:
--start TEXT
: Start station [required]--end TEXT
: Stop station [required]--token TEXT
: Token to talk with the NS API [env var: NS_API_TOKEN; required]--time TEXT
: Time to departure (%H:%M) [default: 12:19]--date TEXT
: Date to departure (%d-%m-%Y) [default: 15-10-2023]--printer-choice [table|ascii|pixelclock]
: [default: ascii]--help
: Show this message and exit.
nstimes update-stations-json
Generate stations lookup, should not be neccesary
Usage:
$ nstimes update-stations-json [OPTIONS]
Options:
--token TEXT
: Token to talk with the NS API [env var: NS_API_TOKEN; required]--path TEXT
: Token to talk with the NS API [env var: NS_API_TOKEN; default: /home/erik/dev/ns_cli/nstimes/stations.json]--help
: Show this message and exit.
Installation
To install, run the following:
pip install nstimes
To verify, run:
nstimes --version
To install auto-completion, run:
nstimes --install-completion
In order for autocomplete to work, one might need to add this to their .zshrc
:
echo -e "\ncompinit -D\n" | tee -a ~/.zshrc
source ~/.zshrc # Reload shell
Obtaining NS token Create an account at the NS API portal. Then create a token here.
Add the token to your shell:
echo -e "\nexport NS_API_TOKEN=****\n" | tee -a ~/.zshrc
source ~/.zshrc # Reload shell
Printers By default, this tool prints in ASCII, e.g.:
IC p. 6 in 6 min (12:28)
IC p. 6 in 18 min (12:40)
SPR p. 6 in 27 min (12:49)
IC p. 6 in 36 min (12:58)
IC p. 6 in 48 min (13:10)
If you use the --printer-choice table
option it prints like:
Journeys from Amersfoort Centraal -> Utrecht
Centraal at 15-10-2023 12:23
┏━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┓
┃ Train ┃ Platform ┃ Leaves in ┃ Departure time ┃
┡━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━━━━━┩
│ IC │ 6 │ 4 min │ 12:28 │
│ IC │ 6 │ 16 min │ 12:40 │
│ SPR │ 6 │ 25 min │ 12:49 │
│ IC │ 6 │ 34 min │ 12:58 │
│ IC │ 6 │ 46 min │ 13:10 │
└───────┴──────────┴───────────┴────────────────┘
It also has support for printing on the Pixel Clock. You just need to add the IP of the clock to your environment variables, e.g. export PIXEL_CLOCK_IP=192.168.0.100
:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.