This is a simple CLI tool that allows you to check the bike status near you with a simple command.
The program allows you to see the bike/dock status of a station close to real-time using Bysykkel's open API. Using Yr's weather API, you can see the weather near stations. The tool supports geolocation search using nearby place names using the Geonames API. This allows a user to find stations in the general area of a given place, without knowing the name of bike stations.
- Clone the code and install the program
git clone git@github.com:gudj0/citybike-cli.git
cd citybike-cli
go install .
- Set up the
.envfile
First, you might want to create a free Geonames account at http://www.geonames.org/login and get your username.
mv .env.example .env
Then edit the .env file and add your Geonames username. You can also change the Yr user agent to your email.
cbike status <place> [OPTIONS] Check the available bike station(s) status
cbike trip <start_place> <end_place> [OPTIONS] Find a bike trip from start to end
cbike list stations List all stations in the system
cbike help Show help
OPTIONS:
-n, --nearby Use geoname search to find nearby stations
-r, --nearby_results N Decides the number of station results when using nearby search (default: 3)
-b, --min-bikes N Filter on minimum number of bikes (default: 0)
-d, --min-docks N Filter on minimum number of docks (default: 0)
-a, --lat <coordinate> Use a specific source latitude (default: 59.9111)
-o, --lon <coordinate> Use a specific source longitude (default: 10.7535)
-e, --debug Debug mode (for now only prints the flags)
-p, --bike_provider <provider> The bike service to use (default: bysykkel)
Check status for the place "majorstua":
$ cbike status majorstua
█████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ [ 9/39] Majorstua skole 55m away ⛅ 12c 6m/s 0.0mm
Check the stations near "Løren":
$ cbike status løren -n
████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ [ 4/21] Lørenveien 115m away 🌧️ 14c 3m/s 2.4mm
███░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ [ 1/15] Bøkkerveien 409m away ⛈️ 14c 3m/s 3.6mm
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ [ 0/19] Lørenporten 526m away 🌧️ 14c 3m/s 2.5mm
Find a trip between A and B
$ cbike trip bjølsen nydalen -n
--------------Source--------------
██████████████████████████████░░░░░░░░░░ [16/20] Bjølsen Studentby 22m away ⛅ 12c 6m/s 0.0mm
██████████████████████████████████░░░░░░ [24/28] Badebakken 222m away ⛅ 12c 6m/s 0.0mm
█████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ [ 3/24] Bentsebrugata 486m away ⛅ 12c 6m/s 0.0mm
------------Destination------------
███████████████████████████████░░░░░░░░░ [14/18] Nydalen 787m away ⛅ 12c 6m/s 0.0mm
███████████████████████████░░░░░░░░░░░░░ [28/42] BI Nydalen 1092m away ⛅ 12c 6m/s 0.0mm
████████████████████████████████░░░░░░░░ [16/20] Rolf Wickstrøms vei 222m away ⛅ 12c 6m/s 0.0mm
You can see that there are plenty of bikes at Bjølsen Studentby, and that there are some vacant docks nearby Nydalen.
The settings.yaml allows you to set default settings without having to specify them in the command line every time. Specifying them in the command line will override the default settings.
settings:
nearby: true
nearby_results: 3
min_bikes: 2
min_docks: 1
location: 59.911491,10.757933
bike_provider: bysykkel
Run the tests with
go test ./...
- Add support for user-input on trip selection for proper distance calculation
- Compare with Ruter's API for trip planning
- Support for more GBFS providers in other cities (e.g., citibike)
- Higher test coverage