Skip to content

Instantly share code, notes, and snippets.

@pfrazee
Last active January 4, 2016 00:59
Show Gist options
  • Save pfrazee/8545051 to your computer and use it in GitHub Desktop.
Save pfrazee/8545051 to your computer and use it in GitHub Desktop.
Trying to add request bodies to the CLI

RESH, the REst SHell

A basic command:

GET foo/bar -Accept=text/html

Rewritten:

GET foo/bar [text/html]

The brackets are a fat pipe. It sets the accept header when it's on the right side of a command.

GET foo/bar [text/html] POST foo/baz

This will pipe the response body of foo/bar into the request body of foo/baz. The fat pipe sets the content-type when it's on the left side.

foo/bar [html] foo/baz

^ Same command, but using default methods (GET if there's no body, POST if there is) and a shorthand mimetype.

So I want to add a way to set the request body in the command, which it doesnt have atm. I'm considering the --, as in:

POST foo/baz --"The Request Body"

But quotes are optional:

POST foo/baz -- The request body

The same, but with a header (and defaulting to POST because of the request body):

foo/baz -Accept=text/html -- The request body

The same, but with the fat pipe:

foo/baz -- The request body [html]

So the left bracket ends the body. If you need left bracks, you quote:

foo/baz -- "The request [body!]" [html]

Work for yall?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment