Piwo
About
Piwo is a friendly command-line tool to do HTTP request to a API server. Sending request body as JSON.
Installation
deno install --allow-net --import-map=https://denopkg.com/crewdevio/piwo@main/import_map.json -n piwo --no-check https://denopkg.com/crewdevio/piwo@main/cli.ts
The permissions that Piwo uses are:
- –allow-net
Updating Piwo
deno install -f -r --allow-net --import-map=https://denopkg.com/crewdevio/piwo@main/import_map.json -n piwo --no-check https://denopkg.com/crewdevio/piwo@main/cli.ts
Check if Piwo has been updated
piwo --version
Using without install
trex exec piwo [...args] or trex exec piwo@[version] [...args]
Usage
Syntax
piwo [method] [url] [body]
Method
: must be uppercase and they can be GET
, POST
, PUT
, PATCH
and DELETE
. If you don’t send a method Piwo will make a GET
(default) request.
Url
: you can omit the protocol (http or https), Piwo will first make a request to https, if the response fails then will make a request with the http protocol.
body
: The body that you will send is a JSON.
If you only write piwo
, then you will see the result of --help
command
Make a GET request
piwo GET https://api.github.com/
A shortest way:
piwo api.github.com
Make a POST, PATCH or PUT request sending a body/JSON
piwo POST localhost:3000/send_your_foo foo=bar
If you need to send a value with spaces, use quotes.
piwo PATCH localhost:3000/update_your_foo foo="this is my bar"
You can also send multiple values, just separing with spaces
piwo POST localhost:3000/signup username=foo password=bar
Make a DELETE request
piwo DELETE localhost:3000/your_foo/remove
Sending a property with array value type
piwo POST localhost:3000/cli/piwo tags=[typescript deno cli http]
Sendin a property with object value type
piwo POST localhost:3000/cli/registry cli={name=piwo description="your friendly HTTP cli tool"}
Some nice tips
How URL argument works
When you’re doing a request you can omit the protocol, Piwo will make a request with https, if get not response then will try with http protocol and then will response with response of the server of a msg that couldn’t connect when no server is found.
When you send the URL with protocol Piwo will not check the other protocol.
If you’re sure that the server is on http protocol, we recommend you to pass the protocol in the url, is faster because piwo will do a direct request with the procotol and will not check the https procotol.
If the url is a localhost, then will try directly with HTTP.
Sending a body
You can separate the values with commas, but a space is always required to differentiate to the others values.
piwo POST localhost:3000/ foo=bar, bar=foo