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

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.0.tar.gz (14.8 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.0-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for starman_cli-1.0.0.tar.gz
Algorithm Hash digest
SHA256 528ac08ca7a8690705a15cb5b4048e83d1904201175c3dc624d5f7d0bb5a97c4
MD5 223e14777dd8aff077d3b40c67fc47c7
BLAKE2b-256 4b27a73dc4927e70faa75e813d35ce61e3051e0afb2f1e649f0c2a7656186f34

See more details on using hashes here.

File details

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

File metadata

  • Download URL: starman_cli-1.0.0-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.8

File hashes

Hashes for starman_cli-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c9eb6c9f5c89ffa0c38c3fd11c95b5f620843753973a100e73eb35cbf40b21bb
MD5 1f541fc93ffa39708d6c2454e77383b2
BLAKE2b-256 bf1248a2f32b649ea38ce91bde9a6f4de2cf54a63ba4fb2b093ec698a767f081

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