Skip to content

Commit

Permalink
Add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
isidentical committed Feb 22, 2022
1 parent 57ef0cb commit 9fcb181
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
20 changes: 20 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2259,6 +2259,26 @@ For managing these plugins; starting with 3.0, we are offering a new plugin mana
This command is currently in beta.
### `httpie cli`
#### `httpie cli export`
`httpie cli export` command was designed to expose parser spec of the `http/`https` commands
(like an API definition) to outside tools so that they can use this to build better interactions
over them (e.g offer auto-complete).
Available formats to export in include:
| format | Description |
|--------|---------------------------------------------------------------------------------------------------------------------------------------------------|
| `json` | Export the parser spec in JSON. The schema includes a top-level `version` parameter which should be interpreted in [semver](https://semver.org/). |
You can use any of these formats with `--format` parameter, but the default one is `json`.
```bash
$ httpie cli export | jq '"Program: " + .spec.name + ", Version: " + .version'
"Program: http, Version: 0.0.1a0"
```
### `httpie plugins`
`plugins` interface is a very simple plugin manager for installing, listing and uninstalling HTTPie plugins.
Expand Down
6 changes: 3 additions & 3 deletions httpie/cli/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def serialize(self) -> Dict[str, Any]:
if self.aliases:
result['options'] = self.aliases.copy()
else:
result['options'] = configuration["metavar"]
result['options'] = configuration['metavar']
result['is_positional'] = True

qualifiers = JSON_QUALIFIER_TO_OPTIONS[configuration.get('nargs', Qualifiers.SUPPRESS)]
Expand Down Expand Up @@ -179,8 +179,8 @@ def to_argparse(


JSON_QUALIFIER_TO_OPTIONS = {
Qualifiers.OPTIONAL: {"is_optional": True},
Qualifiers.ZERO_OR_MORE: {"is_optional": True, "is_variadic": True},
Qualifiers.OPTIONAL: {'is_optional': True},
Qualifiers.ZERO_OR_MORE: {'is_optional': True, 'is_variadic': True},
Qualifiers.SUPPRESS: {}
}

Expand Down
4 changes: 3 additions & 1 deletion httpie/output/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ def __init__(
self,
msg: HTTPMessage,
output_options: OutputOptions,
on_body_chunk_downloaded: Callable[[bytes], None] = None
on_body_chunk_downloaded: Callable[[bytes], None] = None,
**kwargs
):
"""
:param msg: a :class:`models.HTTPMessage` subclass
Expand All @@ -45,6 +46,7 @@ def __init__(
self.msg = msg
self.output_options = output_options
self.on_body_chunk_downloaded = on_body_chunk_downloaded
self.extra_options = kwargs

def get_headers(self) -> bytes:
"""Return the headers' bytes."""
Expand Down

0 comments on commit 9fcb181

Please sign in to comment.