papertrail-cli icon indicating copy to clipboard operation
papertrail-cli copied to clipboard

add papertrail-systems command to list systems

Open samuelcolvin opened this issue 6 years ago • 1 comments

currently I'm using

papertrail-systems() {
    curl -s -H "X-Papertrail-Token: `cat ~/.papertrail.yml | sed -r 's/token://'`" https://papertrailapp.com/api/v1/systems.json | python -m json.tool | grep '"name":' | sed -r 's/ +"name": "(.*)",/\1/'
}

in my .bashrc file.

But it was a faff to setup, would be greate if there was a simpler way of getting this.

samuelcolvin avatar Jan 04 '18 13:01 samuelcolvin

I agree it should be added. But here it is using jq to parse json and yj to convert yml to json (so it can be parsed with jq). While less portable, it's a tad more elegant then regex:

papertrail-systems() {                                                                              
    curl -s -H "X-Papertrail-Token: `cat ~/.papertrail.yml | yj | jq --raw-output .token`" https://papertrailapp.com/api/v1/systems.json | jq --raw-output .[].name
}

bobpaul avatar Jul 18 '20 13:07 bobpaul