1.0.0-alpha.4 • Published 4 years ago

teapicli v1.0.0-alpha.4

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

teapicli

Teapicli is a terminal API client. You can use it to make web requests and inspect responses. It allows you to store and group requests for faster access.

Installation

Install as a global npm package:

npm install -g teapicli

Teapicli is changing rapidly at the moment. In order to get the latest version from master:

git clone git@github.com:schemar/teapicli.git
cd teapicli
yarn
yarn link
yarn build

# Run with node:
node ./dist/cli.js

# Alternatively, link from $PATH, e.g.:
chmod u+x ./dist/cli.js
ln -s $(pwd)/dist/cli.js /usr/local/bin/teapicli

Usage

Basic usage:

teapicli ./my-collection.json

You can check ./examples/collection.json. The collection file defines the requests you will be able to make from within teapicli.

Help output:

Usage: teapicli [options] <collection>

Options:
  -V, --version        output the version number
  -g, --config <file>  alternative configuration file to use
  -t, --client <type>  the client to use for HTTP requests (default: "axios")
  -h, --help           display help for command

Example call:
  $ teapicli ./my-collection.json

Views

ViewExplanation
Main viewThe app opens in the main view. Here you see the collection and can send requests.
SelectorIn the selector you can select an item. For example, when you want to change the selected request of the collection, the selector will open with a list of all requests to select one from.
MessagesLists all messages (including errors and warnings) that teapicli put out.

Commands

ViewKeyCommandEffect
All views:commandType out a command by its name (names from this table).
All viewsqcloseClose the current view and return to the previous view on the stack. When the last view is closed, the application exits.
All viewsmlistMessagesOpen the messages view that lists previous messages.
Main viewssendSend the currently selected request.
Main viewgnextTabRequestSwitch tabs (body, headers) to inspect request.
Main viewhnextTabResponseSwitch tabs (body, headers) to inspect response.
Main viewpshowResponseDisplay the body of the last response in $PAGER.
Main viewrselectRequstOpen the selector to select another request of the collection.
Main viewvselectEnvironmentOpen the selector to select another environment of the collection.
Main vieweeditEdit the collection in your $EDITOR. Make sure to persist with w if you want to keep the changes.
Main viewwwritePersist the current state of the collection to disk.
SelectorjdownMove pointer one line down.
SelectorkupMove pointer one line up.
SelectorsselectSelect item under the current pointer, e.g. the request, and close the selector.

Configuration

Teapicli uses convict to manage configuration.

You can create a configuration file at $HOME/.config/teapicli/config.json. If you do, it will be read on every start of teapicli. You can still override it with the --config CLI option.

The configuration is a JSON file that can change the default configuration. Check Configuration.ts for the available options. For example, to map the quit command to a instead of q, it would look like the following:

{
  "keys": {
    "quit": "a"
  }
}