Comments (24)
You're right, I didn't document that. I'm also not sure wether I'm allowed to give away my (non-production) API key :P
vbb-cli
uses the config
module, which offers configuration either via files or via env variables.
The configuration for vbb-cli
need to look like this:
{"key": "2e9c6a18-8f2e-440c-a8bb-555e85cbeee9"}
As an example, this is how you'd set it in the fish shell:
set -x NODE_CONFIG '{"key": "2e9c6a18-8f2e-440c-a8bb-555e85cbeee9"}'
from vbb-cli.
How do I do this in the zsh or bash? I received my API key, installed config with npm install -g config
, then ran npm set -x NODE_CONFIG '{"key": "lastname-a123-1234-123a-1234abc123"}'
, and it only changed the hidden file ~/.npmrc
while vbb-cli still gives me the error messages:
WARNING: No configurations found in configuration directory:~/config
WARNING: To disable this warning set SUPPRESS_NO_CONFIG_WARNING in the environment.
It seems that vbb-cli is looking in my user folder. Shouldn't it be looking in /usr/local?
from vbb-cli.
How do I do this in the zsh or bash? I received my API key, installed config with npm install -g config, then ran npm set -x NODE_CONFIG '{"key": "lastname-a123-1234-123a-1234abc123"}' […].
This is related to the config
module you mentioned. set -x NODE_CONFIG …
is fish syntax. It just exports a variable to make it accessible to all child processes. For zsh or Bash, it might be something like export NODE_CONFIG=…
.
from vbb-cli.
Thank you. Adding export NODE_CONFIG='{"key": "YourKey"}'
to ~/.bashrc and ~/.zprofile did the trick.
from vbb-cli.
Thank you. Adding export NODE_CONFIG='{"key": "YourKey"}'to ~/.bashrc and ~/.zprofile did the trick.
If you don't want this permanently, just run the command. NODE_CONFIG
will then be exported until you close the shell.
from vbb-cli.
There seem to be some problems doing this in a shell script running in BitBar. One of the reasons seems to be that BitBar uses its own instance of the bash, so global settings that work fine for running a script directly in the shell don't work in this instance. Therefore the first thing is to add
export PATH=$HOME/local/node/bin:/usr/local/bin:$PATH
to the script. vbb-stations
then runs fine. However, problems appear with the vbb-cli:
For the same reason the global setting of the API access ID doesn't work. I tried adding the following commands at the beginning of the script, but to no avail:
ACCOUNT=$(who am i | /usr/bin/awk {'print $1'})
API_ID=$(/usr/bin/security 2>&1 >/dev/null find-generic-password -s VBBar -ga "$ACCOUNT" | /usr/bin/ruby -e 'print $1 if STDIN.gets =~ /^password: "(.*)"$/')
export NODE_CONFIG='{"key": "$API_ID"}'
Reading the ID from the Keychain works great; exporting it doesn't. In BitBar I'm getting error messages (see the appended .png). When running the script directly in the shell, the export NODE_CONFIG
line obviously overrides global settings, and then I'm also getting error messages, but different ones:
StatusCodeError: 403 - [object Object]
at new StatusCodeError (/usr/local/lib/node_modules/vbb-cli/node_modules/request-promise/lib/errors.js:26:15)
at Request.RP$callback [as _callback] (/usr/local/lib/node_modules/vbb-cli/node_modules/request-promise/lib/rp.js:68:32)
at Request.self.callback (/usr/local/lib/node_modules/vbb-cli/node_modules/request/request.js:200:22)
at emitTwo (events.js:106:13)
at Request.emit (events.js:191:7)
at Request.<anonymous> (/usr/local/lib/node_modules/vbb-cli/node_modules/request/request.js:1067:10)
at emitOne (events.js:101:20)
at Request.emit (events.js:188:7)
at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/vbb-cli/node_modules/request/request.js:988:12)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:926:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
So I assume that you need to go about differently, when exporting the API key within the script. Any ideas?
(Also posted about the problem in the BitBar issues forum, albeit with less information.)
from vbb-cli.
PS: For a moment I thought that the problem could be that I'm running vbb-dep
in a bash loop in my test script:
echo "$NEARBY_ID_LIST" | while IFS= read -r STATION_ID
do
DEPARTURES=$(/usr/local/bin/vbb-dep "$STATION_ID" -r 8)
STATION_RAW=$(/usr/local/bin/vbb-stations --id $STATION_ID --format csv)
STATION_NAME=$(echo "$STATION_RAW" | /usr/local/bin/mlr --icsv --onidx --ofs @ --rs lf cut -f name)
STATION_LAT=$(echo "$STATION_RAW" | /usr/local/bin/mlr --icsv --onidx --ofs @ --rs lf cut -f latitude)
STATION_LONG=$(echo "$STATION_RAW" | /usr/local/bin/mlr --icsv --onidx --ofs @ --rs lf cut -f longitude)
echo "$STATION_NAME"
echo "--COORDINATES: $STATION_LAT,$STATION_LONG" # placeholder ALT ???
echo "-----"
echo "$DEPARTURES" | /usr/bin/sed "s/^[ \t]*//" | /usr/bin/awk '{$1="--"$1; print}'
echo "-----"
echo "--Show in Maps | terminal=false bash=$0 param1=show-nearby"
done
So I tried exporting NODE_CONFIG within the while read line loop, but that didn't change anything.
from vbb-cli.
For the same reason the global setting of the API access ID doesn't work. I tried adding the following commands at the beginning of the script, but to no avail:
ACCOUNT=$(who am i | /usr/bin/awk {'print $1'}) API_ID=$(/usr/bin/security 2>&1 >/dev/null find-generic-password -s VBBar -ga "$ACCOUNT" | > /usr/bin/ruby -e 'print $1 if STDIN.gets =~ /^password: "(.*)"$/') export NODE_CONFIG='{"key": "$API_ID"}'
I don't know exactly about Bitbar's handling of shell scripts, I also don't have any experience with it. Please ask in their issues.
I can confirm exporting works with both bash
and fish
. Also, you may get rate-limited if you do too many requests from your IP, but that's again something I can't influence (VBB's decision).
Reading the ID from the Keychain works great; exporting it doesn't. In BitBar I'm getting error messages (see the appended .png). When running the script directly in the shell, the
export NODE_CONFIG
line obviously overrides global settings, and then I'm also getting error messages, but different ones:StatusCodeError: 403 - [object Object] at new StatusCodeError (/usr/local/lib/node_modules/vbb-cli/node_modules/request-promise/lib/errors.js:26:15)
With the most recent commit on vbb-cli
(not released to npm yet), it should show more helpful error messages instead of `
from vbb-cli.
Please note that vbb-cli
is not made for scripted, but rather for interactive usage. You might try, but it doesn't output machine-readable data.
Also, check vbb-rest
, which I made in the last days. It intends to become an HTTP API covering all developers' needs.
from vbb-cli.
Please note that
vbb-cli
is not made for scripted, but rather for interactive usage. You might try, but it doesn't output machine-readable data.
Running vbb-route
with the -r 1
option …
vbb-route 9023201 9100003 -r 1 -w "2016-05-15 15:00"
and running vbb-dep
with standard settings …
vbb-dep 9023201 -r 8 -w "2016-05-15 15:00"
produces normal output, which you can use in a script. I would just have to trim leading whitespace and blank lines… and convert AM/PM times to the standard format.
Also, check
vbb-rest
, which I made in the last days. It intends to become an HTTP API covering all developers' needs.
Will do that. Whatever works. :)
As for the issue: Exporting the API key in bashrc and zprofile works, and vbb-dep/vbb-route work great in the normal shell. BitBar however seems to be a "bit" different. Hopefully I'll find a way.
Will test it again when the new vbb-cli version is available.
from vbb-cli.
PS: will vbb-rest
contain the option to select routes based on arrival times? That's something I'm still thinking about how to implement using vbb-route
.
from vbb-cli.
PS: will vbb-rest contain the option to select routes based on arrival times? That's something I'm still thinking about how to implement using vbb-route.
I plan to put it as an API parameter.
from vbb-cli.
I've now actually gotten it to work in BitBar. It seems that an additional xargs
was necessary, and to get out of the single quotes before passing the API key in the export
command. However, even though it's working, there are still vbb-dep
errors. I can, of course, suppress them with 2>/dev/null
, which is what I've already done in the version of the script below, but I wanted to let you know (see the appended png).
#!/bin/bash
export PATH=/usr/local/bin:$PATH
ACCOUNT=$(who am i | /usr/bin/awk {'print $1'})
API_ID=$(/usr/bin/security 2>&1 >/dev/null find-generic-password -s VBBar -ga "$ACCOUNT" | /usr/bin/ruby -e 'print $1 if STDIN.gets =~ /^password: "(.*)"$/' | xargs)
export NODE_CONFIG='{ "key": "'"$API_ID"'" }'
echo "VBB | dropdown=false"
echo "---"
echo "$ACCOUNT"
echo "$API_ID"
echo "---"
STATION_ID="9100003"
STATION_INFO=$(/usr/local/bin/vbb-stations --id "$STATION_ID")
echo "$STATION_INFO"
DEPARTURES=$(/usr/local/bin/vbb-dep "$STATION_ID" -r 8 2>/dev/null)
echo "$DEPARTURES"
from vbb-cli.
I strongly recommend you to write a custom JS scripts. Then you won't have formatting problems (vbb-cli
is optimized for monospace fonts, Bitbar shows non-monospace fonts), output parsing, exporting of shell variables. You can directly use vbb-hafas
and vbb-stations
like you want.
from vbb-cli.
That's no problem. You have lots of formatting options in BitBar. Here's a quick test with AndaleMono and some coloring scheme, based on awking $1 of each line.
from vbb-cli.
That's no problem. You have lots of formatting options in BitBar.
Nice! But still, if there's lot of options, you could show inline images, links, make stuff clickable...
from vbb-cli.
there are still
vbb-dep
errors
Regarding this "process.stdout.unref
: It sounds weird, but I need process.stdout.unref, otherwise the process doesn't exit. [The documentation](https://nodejs.org/api/dgram.html#dgram_socket_unref) doesn't help a lot unfortunately. I'm pretty sure it's related to my prompt modules used by
vbb-cli`, although I couldn't find any solution in other prompts' code & issues.
Maybe with a non-tty process.stdout
, unref
fails.
from vbb-cli.
Nice! But still, if there's lot of options, you could show inline images, links, make stuff clickable...
Yes, that's the whole point. :) There will be no background automation except for local coordinates and determining nearby stations (and their addresses!), default 500m radius… or more, depending on user settings. Departures are only loaded through vbb-cli when the user clicks the "Refresh" menu item. There will be other stuff, e.g. pressing the ALT key will show the address instead of the name of the station, and clicking on it will open the walking route from the current location to the station in Apple Maps. As for inline images, that's tricky. I think the only thing that works are emojis. I have a VBBar icon encoded with Base64, but that's only for the menu bar, not for the lines in the menu. Maybe there is some workaround. I would have to look into that.
As for the vbb-dep errors, I assume it has something to do with BitBar. When I run the BitBar test script directly in the normal shell (in Terminal or iTerm), everything works fine, as it should… no error messages. They only appear in BitBar, but as long as they don't interfere with the operation and I can send them to null, it shouldn't be a problem. (I hope.)
from vbb-cli.
As for the vbb-dep errors, I assume it has something to do with BitBar. When I run the BitBar test script directly in the normal shell (in Terminal or iTerm), everything works fine, as it should… no error messages. They only appear in BitBar, but as long as they don't interfere with the operation and I can send them to null, it shouldn't be a problem. (I hope.)
As I said: If you run a script in a terminal, its stdout
is in tty mode. If you, on the other hand, pipe stdout
to something like Bitbar, it will be in non-tty mode and this is where unref()
fails AFAIK.
from vbb-cli.
There will be other stuff, e.g. pressing the ALT key will show the address instead of the name of the station, and clicking on it will open the walking route from the current location to the station in Apple Maps. As for inline images, that's tricky. I think the only thing that works are emojis. I have a VBBar icon encoded with Base64, but that's only for the menu bar, not for the lines in the menu. Maybe there is some workaround. I would have to look into that.
Show me the repo, so we can discuss this further!
from vbb-cli.
I'll let you know as soon as it's up. But atm I'm still meddling with the test scripts, which will eventually wind up as sub-routines in the final script.
from vbb-cli.
I'll let you know as soon as it's up. But atm I'm still meddling with the test scripts, which will eventually wind up as sub-routines in the final script.
Why not upload it now? Openness and feedback are nice! 😛
from vbb-cli.
Very soon. Almost finished with the v0.1 alpha. The final issues are: (a) migrating from Google's Geocoding API to Mapbox (coordinates > address; walking distance/walking route to stations); (b) calculating departure times in HH:MM from vbb-dep output (columns $3, $4), also taking into account negative values like -7m, -26s etc.; (c) setting up printing jobs for departures per station; (d) but mainly I also have to test it first, especially for traffic hubs like Potsdamer Platz… there's always a nasty bug lurking around. ;) As soon as that's finished, I'll upload it. Promise. :) Couple of working days, maybe next week or so.
By the way: for looking up stations near addresses I'm currently cURLing the Straßenverzeichnis Berlin on the kauperts website. Do you by chance know of an actual maintained database of Berlin street names (incl. PLZ, Bezirk)?
from vbb-cli.
As soon as that's finished, I'll upload it. Promise. :)
Why not now? It doesn't have to polished to be on GitHub.
By the way: for looking up stations near addresses I'm currently cURLing the Straßenverzeichnis Berlin on the kauperts website. Do you by chance know of an actual maintained database of Berlin street names (incl. PLZ, Bezirk)?
Haven't dealt with that yet. You may try http://daten.berlin.de/datensaetze/stra%C3%9Fenverzeichnis.
Or ask on the OKlab Berlin, that's where I am frequently.
from vbb-cli.
Related Issues (11)
- rename route -> journey
- Problem installing via npm HOT 4
- lines is not defined HOT 3
- Geo location not working HOT 2
- Neither `from` nor `fromLatitude` & `fromLongitude` passed. HOT 1
- create a command line lib for any HAFAS client HOT 10
- vbb-dep problem HOT 1
- "Bad Gateway" HOT 5
- products filter not working HOT 4
- write a Deutsche Bahn clone HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vbb-cli.