req

command module
v0.0.0-...-906d765 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 23, 2021 License: MIT Imports: 1 Imported by: 0

README

req

A simple cli to send http requests.

Navigate

Why

I created req mainly to use it with Rofi. At home, I can control domotics directly from Rofi.

Check the Rofi section below.

Demo

asciicast

Install

Use precompiled versions in releases page

or

go get -u github.com/itsjimi/req

Usage

First of all, you need to create a .req.json in your home directory.

Config file

This is the most common .req.json.

[
  {
    "name": "Get first post",
    "url": "https://jsonplaceholder.typicode.com/posts/1",
    "method": "GET"
  }
]
List

You can list all of available requests by running.

req list

In our case we have one element displayed.

Get first post
Run

You can run one or multiple requests by using run command.

req run "Get first post"

The result is displayed on terminal.

{
  "userId": 1,
  "id": 1,
  "title": "...",
  "body": "..."
}

Reference

Config file

By default, .req.json must be in your home directory.

[
  {
    "name": "Get first post",
    "url": "https://jsonplaceholder.typicode.com/posts/1",
    "method": "GET",
    "output": "echo \"Title: {{.title}}\nBody: {{.body}}\""
  },
  {
    "name": "Create post",
    "url": "https://jsonplaceholder.typicode.com/posts",
    "method": "POST",
    "headers": [
      "Content-type: application/json; charset=UTF-8"
    ],
    "body": {
      "title": "foo",
      "body": "bar",
      "userId": 1
    }
  }
]

output exec commands with bash and use go template to replace variables.

Commands
  • All commands can use --help or -h to display its specific help.
  • All commands can use --config or -c to use a custom .json path. (By default req use a .req.json in your home directory)
help

Display helper

req help
version

Display version req using SemVer.

req version
list

Display list of .req.json requests names (each separated by \n).

req list
run

Send one or multiple requests and display results.

Note: You can use --silent or -s to display nothing.

req run <request name> [other request name] [...]
Rofi

Req can be used in rofi with the rofi-req.sh script. rofi-req

Contribute

Feel free to fork and make pull requests.

License

MIT

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL