Skip to main content

The RIPEStat CLI

A command line wrapper for the RIPEStat API.

How it Works

ripestat maxmind-geo-lite 193.0.6.158
193.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 │
╘═══════════╧════════╧══════════════╧════════════╧═════════════════════════════════════════════════╛

Installation

It's a python program, so you install it with pip:

$ pip install ripe.stat.cli

However, since it's a command-line tool, you might want to consider using pipx to install it, as it will then be automatically added to your ${PATH} and pipx will handle the virtualenv shenanigans for you:

$ pipx install ripe.stat.cli

Tab Completion

One of the nicer quirks of this tool is the tab completion. You can do handy stuff like ripestat ma<tab> and it'll autocomplete ripestat maxmind-geo-lite for you. If you want to enable that, you need a few things:

  1. Install argcomplete. This is a dependency of ripestat-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 like apt install python-argcomplete or pacman -S python-argcomplete for example.
  2. Once installed, you just have to enable autocompletion as per the official docs. In short, this means running this on Debian-based systems:
    $ sudo activate-global-python-argcomplete
    
    or this on Arch-based systems:
    $ sudo activate-global-python-argcomplete --dest /usr/share/bash-completion/completions
    
    Alternatively, 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:
    $ sudo activate-global-python-argcomplete --dest=-
    

Extending

This little project doesn't yet support all of RIPEStat's many, many endpoints, but extending it to do so is quite easy if you're motivated:

  1. Create a folder under ripe/stat/cli/templates named for the endpoint exactly as it appears in the API. For example, the AS Overview folder would be named as-overview because that's what you see in the URL.
  2. 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 called resource.
  3. Finally, create a Jinja template in that same folder called template.jinja. This template will be handed the contents of the data portion 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.
  4. Optionally, you can also add your own filters to ripe/stat/cli/filters.py. Currently, we have colourise() and as_table() in there, but if you need something special, this is where you probably want to put it.

TODO

For 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:

  1. 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.
  2. 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.

Metadata

Release files for ripe.stat.cli 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ripe.stat.cli 0.1.0
File Size Uploaded
ripe.stat.cli-0.1.0.tar.gz 46.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ripe.stat.cli 0.1.0
File Interpreter ABI Platform
ripe.stat.cli-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 94.9 kB

Release files / ripe.stat.cli-0.1.0.tar.gz

Download URL ripe.stat.cli-0.1.0.tar.gz
Size 46.4 kB
Tags Source
SHA-256 checksum
How to use checksums
c55207df9ccfe20695cdbb932c944685df0f5943e3dda6c490ea09bf4e519b0f
BLAKE2b-256 checksum
How to use checksums
50acd4337128fbe6589551475c17e3ab95b8efbb43498b4fdf24bcccf50a9e22
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.10.5 Linux/5.18.7-arch1-1

Release files / ripe.stat.cli-0.1.0-py3-none-any.whl

Download URL ripe.stat.cli-0.1.0-py3-none-any.whl
Size 48.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7e5f4f21ae6e6e38e8ea177ecccf95ef585e9f14a574faf82f30d4ec9c236bf0
BLAKE2b-256 checksum
How to use checksums
fba62d4292cae3072b3344be74d3944282a94f3ab27191abc64492e2f558cf89
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.10.5 Linux/5.18.7-arch1-1

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page