aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--LICENSE14
-rw-r--r--Makefile24
-rw-r--r--README.md65
3 files changed, 103 insertions, 0 deletions
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..5a8e332
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,14 @@
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+ Version 2, December 2004
+
+ Copyright (C) 2004 Sam Hocevar <[email protected]>
+
+ Everyone is permitted to copy and distribute verbatim or modified
+ copies of this license document, and changing it is allowed as long
+ as the name is changed.
+
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. You just DO WHAT THE FUCK YOU WANT TO.
+
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..dc3810d
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,24 @@
+SCRIPT_NAME := rest-run
+
+ZSH_COMPLETION_DIR := /usr/local/share/zsh/site-functions
+
+prefix := /usr/local
+bindir := $(prefix)/bin
+
+install: install-bin install-zsh-completion
+
+install-bin:
+ mkdir -p $(bindir)
+ install -m 755 $(SCRIPT_NAME) $(bindir)/$(SCRIPT_NAME)
+
+install-zsh-completion:
+ mkdir -p $(ZSH_COMPLETION_DIR)
+ install -m 755 ./completions/zsh/_$(SCRIPT_NAME) $(ZSH_COMPLETION_DIR)/_$(SCRIPT_NAME)
+
+uninstall: uninstall-bin uninstall-zsh-completion
+
+uninstall-bin:
+ -rm $(bindir)/$(SCRIPT_NAME)
+
+uninstall-zsh-completion:
+ -rm $(ZSH_COMPLETION_DIR)/_$(SCRIPT_NAME)
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..de62dc6
--- /dev/null
+++ b/README.md
@@ -0,0 +1,65 @@
+# rest-run
+## Postman? Never heard of it! rest-run is the only REST API client you will ever need!
+
+### Dependencies
+
+* Ranger file manager
+* HTTPie
+* esh template engine
+
+### Instalation
+
+If you have GNU Make installed run a
+```sh
+make install
+```
+
+Otherwise just copy the rest-run script to some directory on your $PATH
+
+### Usage
+
+```sh
+# pipe JSON body to rest-run
+cat /tmp/body.json | rest-run http://localhost:8080/api/path --body stdin
+
+# create a PUT request, the default editor will be called to compose the request body
+rest-run PUT http://localhost:8080/api/resource
+
+# replay last request according to the API path, skip editting request body
+rest-run PUT http://localhost:8080/api/resource -b last -ne
+
+# pick request response from history according to the API path and read it with a pager
+rest-run PUT http://localhost:8080/api/resource -r last -p
+```
+
+###### Positional arguments
+
+You must provide the API URL. An HTTP verb preceding it is accepted if present.
+
+###### Options
+
+* -x|--method HTTP Method
+* -b|--body Request body source, must be one of the following options:
+ * default - create a request body using the default editor
+ * last - use the last request
+ * history - pick from the request history
+ * stdin - reads from piped input
+* -r|--response Request response handling, must be one of the following options:
+ * default - store the request on cache
+ * last - read last request, skip request
+ * history - pick from the response history, skip request
+* -ne|--no-edit Skip request editting. Ignored when --body is set to default
+* -h|--header Header string. Ex: "Authorization: Bearer 123"
+* -p|--paginate Paginate request response
+
+rest-run parses your request body with a simple template engine called esh. You can embed shell scripts/commands in your request file surrouning it with <% my-command %> or <%= $MY_ENV_VARIABLE %>
+
+Example:
+```sh
+ echo '{
+ "username": "<%= $USER %>",
+ "device": "<%= $HOSTNAME %>",
+ "created_at": "<% date +"%FT%T.000Z" %>",
+ "password": 123
+ }' | rest-run POST https://postman-echo.com/post
+```