Skip to main content

A CLI tool for executing customizable API requests

Project description

starman-cli

A CLI tool for executing customizable API requests

  ____ _____  _    ____  __  __    _    _   _ 
 / ___|_   _|/ \  |  _ \|  \/  |  / \  | \ | |
 \___ \ | | / _ \ | |_) | |\/| | / _ \ |  \| |
  ___) || |/ ___ \|  _ <| |  | |/ ___ \| |\  |
 |____/ |_/_/   \_\_| \_\_|  |_/_/   \_\_| \_|

Sometimes you want to be able to submit quick http requests from the command-line, without having to look up curls in your bash history or switch to Postman to locate a request. This is where Starman comes in.

Starman provides a way to manage sets of http requests as commands that you can execute with a few simple keywords. Sets of commands are managed via charts, and Starman allows you to easily add and share charts to make new http requests available.

Setting Up Starman

Starman is run using Python (3.5+).

Setup with pip install

The easiest way to set up the CLI is to run:

pip install starman-cli

Setup with source code

Alternatively the CLI can be executed by pulling the source code and creating an alias on starman/cli.py, e.g.

alias starman="python ~/Code/starman-cli/starman/cli.py

Required packages may need to be installed:

pip install -r requirements.txt

To address any SSL configuration issues:

pip config set global.trusted-host "pypi.org files.pythonhosted.org pypi.python.org"

Using Starman

To see the available commands for the current chart, run starman space describe:

> starman space describe

SAMPLE
=============================
Sample chart using ReqRes API

CHART LOCATION:
/path/to/chart/directory

AVAILABLE COMMANDS:
- delete
- get
- get users
- get other
- post

The listed commands can then be run via starman COMMAND.

> starman get

{
  "data": {
    "id": 1,
    "email": "george.bluth@reqres.in",
    "first_name": "George",
    "last_name": "Bluth",
    "avatar": "https://reqres.in/img/faces/1-image.jpg"
  },
  "support": {
    "url": "https://reqres.in/#support-heading",
    "text": "To keep ReqRes free, contributions towards server costs are appreciated!"
  }
}

Additional details on each command can be provided using starman space describe COMMAND.

> starman space describe get other

get other
=============================
GET /api/users/{{user_id}}
Example doing a GET request specifying a user_id

REQUIRED PARAMETERS:
- user_id

When describing specific command, you'll sometimes see that some commands have required parameters. The CLI will first try to pull the parameter from the CLI state; failing that the parameter will need to be provided as part of the starman command. This can be done using the --param/-p argument, followed by a key-value pair of the parameter you are trying to set.

> starman get other --param user_id=1

It's also possible to set / replace the payload used for requests, using the --data/-d argument.

> starman post --data @data.json

If the provided argument value starts with @, the CLI will assume the value is a filepath and will use its contents for the payload. Otherwise the value itself will be used for the payload. Some requests may require the payload to be set in order to execute.

Managing Starman

Besides the commands that are associated with specific charts, the CLI supports a collection of commands to manage the overall workspace (all prefixed with the space keyword).

For example, you can view the current CLI state with the command starman space state.

> starman space state

CURRENT_CHART:		sample
CURRENT_ENVIRONMENT:	default
=============================
name: morpheus
user_id: '787'

Management commands suported by the CLI:

  • starman space list charts
    • List the available charts for the CLI
  • starman space list environments
    • List the available environments for the CLI
  • starman space add chart CHART PATH
    • Add a chart to be tracked by the CLI
  • starman space remove chart CHART
    • Remove a tracked chart; this will clear any state values for the chart
  • starman space target chart CHART
    • Select the chart the CLI should be using
  • starman space target environment ENV
    • Select the environment that CLI should be using
  • starman space describe
    • Describes the available commands for the current chart
    • By including the command with the request (e.g. starman space describe get resource), you can get additional details on a specific command
  • starman space state
    • Presents the current CLI state, as well as the current chart and environment
      • State values that are secrets will be masked
    • Just returns the specific parameter value with starman space state PARAMETER
      • Secret state values are not masked in this case
    • Update the parameter value with starman space state PARAMETER=VALUE

Extending Starman

By default the only chart Starman includes is the sample chart. Additional charts can be added by running the starman space add chart CHART PATH command.

You can also write your own charts! More information can be found here.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

starman_cli-1.0.2.tar.gz (14.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

starman_cli-1.0.2-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file starman_cli-1.0.2.tar.gz.

File metadata

  • Download URL: starman_cli-1.0.2.tar.gz
  • Upload date:
  • Size: 14.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.10

File hashes

Hashes for starman_cli-1.0.2.tar.gz
Algorithm Hash digest
SHA256 4e9ffa078c1ac03281e2175b642b1b438315c876d008a5f792bfe9b35431d015
MD5 88064ccf8c3e62ece26fcb81efc0b730
BLAKE2b-256 3ccd8c28db5ab589180abc3189f1710cd3e3a6ea6af08ce439f9a84a2ec3453f

See more details on using hashes here.

File details

Details for the file starman_cli-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: starman_cli-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 16.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.10

File hashes

Hashes for starman_cli-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 83f4a6cfe81b8848d04f25f610cc3ee3dd0dd12e0aa89f06abe8c4ce78b1197e
MD5 61f9145cbd3e7577619dab41413fc968
BLAKE2b-256 7aa34334522b2990c4a4b6ba6b3eee7296735322f1e78793d8f3746cf48ffc50

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page