Package: ripe.stat.cli
The RIPEStat CLIA command line wrapper for theRIPEStat API.How it Worksripestatmaxmind-geo-lite193.0.6.158193.0.6.158/32
╒═══════════╤════════╤══════════════╤════════════╤═════════════════════════════════════════════════╕
│Country│City│Resources│Coverage│URL│
╞═══════════╪════════╪══════════════╪════════════╪═════════════════════════════════════════════════╡
│NL││193.0.0.0/20│100│https://www.google.com/maps/@52.3824,4.8995,12z│
╘═══════════╧════════╧══════════════╧════════════╧═════════════════════════════════════════════════╛InstallationIt's a python program, so you install it withpip:$pipinstallripe.stat.cliHowever, since it's a command-line tool, you might want to consider usingpipxto install it, as it will then be automatically added to your${PATH}and
pipx will handle the virtualenv shenanigans for you:$pipxinstallripe.stat.cliTab CompletionOne of the nicer quirks of this tool is the tab completion.  You can do handy
stuff likeripestat ma<tab>and it'll autocompleteripestat maxmind-geo-litefor you.  If you want to enable that, you need a few things:Install argcomplete.  This is a dependency ofripestat-cli, so it'll be
available in the virtualenv, but that may not be convenient.  You can always
install this with your operating system's package manager.  Something likeapt install python-argcompleteorpacman -S python-argcompletefor
example.Once installed, you just have to enable autocompletion as per theofficial docs.
In short, this means running this on Debian-based systems:$sudoactivate-global-python-argcompleteor this on Arch-based systems:$sudoactivate-global-python-argcomplete--dest/usr/share/bash-completion/completionsAlternatively, you can also install it at the user-level by dumping the
output of this command into a file that's sourced at login time:$sudoactivate-global-python-argcomplete--dest=-ExtendingThis little project doesn't yet supportallof RIPEStat's many,manyendpoints, but extending it to do so is quite easy if you're motivated:Create a folder underripe/stat/cli/templatesnamed for the endpoint
exactly as it appears in the API.  For example, theAS Overviewfolder would be namedas-overviewbecause that's what you see in the URL.In that folder create a file called:spec.json.  The contents of which can
just be copied from one of the existing folders.  The idea is to expand this
in the future should we want to support things like sorting or different
arguments etc.  For now though, it just tells the command handler that we
need to accept an argument calledresource.Finally, create a Jinja template in that same folder calledtemplate.jinja.  This template will be handed the contents of thedataportion of the API response.  You have all the powers that Jinja grants you
in there, so go nuts.  If you're looking for inspiration, just look at same
file in the other folders.Optionally, you can also add your own filters toripe/stat/cli/filters.py.
Currently, we havecolourise()andas_table()in there, but if you need
something special, this is where you probably want to put it.TODOFor the most part, this does you'd expect -- at least for the few endpoints
currently supported.  There are two glaring things that really should be done
soon though:Error handling: If the RIPEStat API barks at you with an error, this script
should print out a user-friendly message, maybe with some emojis and some
nice colour.  At the moment, it just explodes.Tests: There aren't any!  Unit tests for each filter & formatter are a bare
minimum, but an end-to-end test for each endpoint would be ideal.