1
0
mirror of https://github.com/httpie/cli.git synced 2026-05-04 20:44:57 +02:00

cmd: Implement httpie plugins interface (#1200)

This commit is contained in:
Batuhan Taskaya
2021-11-30 11:12:51 +03:00
committed by GitHub
parent 6bdcdf1eba
commit 245cede2c2
23 changed files with 1075 additions and 62 deletions
+69
View File
@@ -1880,6 +1880,11 @@ $ cat ~/.config/httpie/config.json
3) echo 'Unexpected HTTP 3xx Redirection!' ;;
4) echo 'HTTP 4xx Client Error!' ;;
5) echo 'HTTP 5xx Server Error!' ;;
6) echo 'Exceeded --max-redirects=<n> redirects!' ;;
*) echo 'Other Error!' ;;
esac
fi
```
### Best practices
@@ -1919,6 +1924,70 @@ And since there’s neither data nor `EOF`, it will get stuck. So unless you’r
> By default the plugins (and their missing dependencies) will be stored under the configuration directory,
but this can be modified through `plugins_dir` variable on the config.
#### `httpie plugins install`
For installing plugins from [PyPI](https://pypi.org/) or from local paths, `httpie plugins install`
can be used.
```bash
$ httpie plugins install httpie-plugin
Installing httpie-plugin...
Successfully installed httpie-plugin-1.0.2
```
> Tip: Generally HTTPie plugins start with `httpie-` prefix. Try searching for it on [PyPI](https://pypi.org/search/?q=httpie-)
> to find out all plugins from the community.
#### `httpie plugins list`
List all installed plugins.
```bash
$ httpie plugins list
httpie_plugin (1.0.2)
httpie_plugin (httpie.plugins.auth.v1)
httpie_plugin_2 (1.0.6)
httpie_plugin_2 (httpie.plugins.auth.v1)
httpie_converter (1.0.0)
httpie_iterm_converter (httpie.plugins.converter.v1)
httpie_konsole_konverter (httpie.plugins.converter.v1)
```
#### `httpie plugins uninstall`
Uninstall plugins from the isolated plugins directory. If the plugin is not installed
through `httpie plugins install`, it won't uninstall it.
```bash
$ httpie plugins uninstall httpie-plugin
```
## Meta
### Interface design
The syntax of the command arguments closely correspond to the actual HTTP requests sent over the wire.
It has the advantage that it’s easy to remember and read.
You can often translate an HTTP request to an HTTPie argument list just by inlining the request elements.
For example, compare this HTTP request:
```http
POST /post HTTP/1.1
Host: pie.dev
X-API-Key: 123
User-Agent: Bacon/1.0
Content-Type: application/x-www-form-urlencoded
name=value&name2=value2
```
with the HTTPie command that sends it:
```bash
$ http -f POST pie.dev/post \
X-API-Key:123 \
User-Agent:Bacon/1.0 \
name=value \
name2=value2
```