Rat

RAT - the Rest Api Tool

Rat is a simple command line tool that helps me automate repetitive tasks for my favorite web services and software products which expose a REST API. The general guideline for all commands rat supports is that they should perform only one thing preferably with one HTTP call only. This guideline follows the UNIX principle that tools should do one thing and complex behaviour is achieved by pipelining.

Linux & OS X Build Status Windows Build status MIT licensed

Table of Contents

Available Clients

CenterDevice

rat centerdevice auth
rat centerdevice collections
rat centerdevice delete
rat centerdevice download
rat centerdevice refresh_token
rat centerdevice search
rat centerdevice status
rat centerdevice upload

Pocket

rat pocket auth
rat pocket list
rat pocket archive
rat pocket readd
rat pocket favorite
rat pocket unfavorite
rat pocket delete

Slack

rat slack auth

Stocks

rat stocks

Installation

macOS

Please use Homebrew to install rat on your system.

brew install lukaspustina/os/rat

Ubuntu

Pleae add my [PackageCloud] open source repository and install rat via apt.

curl -s https://packagecloud.io/install/repositories/lukaspustina/opensource/script.deb.sh | sudo bash
sudo apt-get install rat

Windows

rat is automatically build on Windows via AppVeyor to ensure is compiles and runs fine but binaries are currently not provided. Please compile it from source.

From Source

Please install Rust via rustup and then run

cargo install rat

Usage

General

There are two response output modes, i.e., JSON and HUMAN, and three message levels, i.e., QUIET, NORMAL, and VERBOSE.

In human output mode tries to give a concise representation if the received information. In json output mode, rat tries to pass the whole json response to the user – if any is available. The output mode can be selected with the parameter --output <humen|json>, e.g., rat --output json ...

The message output levels configure how talkative rat is during execution. The quiet level reduces outputs to real responses only while the normal level tries to give some feedback to the user about the start and end of a request. The verbose level goes one step further and tries to inform the user about each step of the processing. The message level can be chosen with the parameters --quiet or --verbose, respectively. If none of these switches is activated, the message level is set to normal. For example, rat --verbose ... selects the verbose message level.

CenterDevice

Authenticate rat

rat centerdevice auth and follow the instructions.

Refresh access token

rat centerdevice refresh_token

Search collection

Download document

Search document

Upload document

Delete document

rat centerdevice delete excbd68a-c397-id46-9350-a4fd4022fe8c

Pocket

Authentication

Create a consumer key

Create a new application and add the newly created consumer key to your rat configuration, section [pocket] as consumer_key = '<consumer key'.

Authenticate rat

rat pocket auth and follow the instructions.

Archive | Readd | Favorite | Unfavorite | Delete

rat pocket archive|readd|favorite|unfavorite|delete <article ids>...

Search in title and URL of all articles …

List all …

Advanced listing

Slack

Authentication

Create client ID and client Secret

Create a new application and add the newly created Client ID and Client Secret to your rat configuration, section [slack] as client_id = '<client id>' and client_secret = '<client secret', respectively.

Authenticate rat

rat slack auth and follow the instructions.

Stocks

Scrape current stock price from comdirect web page


Clients to Come

rat feedly

rat elasticsearch browse
rat elasticsearch status -- curl -s http://<host>:9200/_cluster/health?level=shards
rat elasticsearch health -- curl -s http://<host>:9200/_cluster/health

rat slack channel list
rat slack user list
rat slack send <channel|user> <message>

rat bosun browse
rat bosun incidents show --open
rat bosun incidents ack|close --ids  <id>,<id> --message "Just because ..."
rat bosun show-silences
rat bosun silence show
rat bosun silence set

Todos

– Before first 1.0 release


References

Pocket

Rust

Crates

Credits