Skip to content

Commit

Permalink
Decouple parser definition from argparse (#1293)
Browse files Browse the repository at this point in the history
  • Loading branch information
isidentical committed Mar 7, 2022
1 parent 7509dd4 commit 77af4c7
Show file tree
Hide file tree
Showing 12 changed files with 711 additions and 297 deletions.
21 changes: 21 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2402,6 +2402,27 @@ 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-args`
`httpie cli export-args` command can expose the parser specification of `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-args | 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
8 changes: 7 additions & 1 deletion httpie/cli/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,19 @@
})

# Pretty


class PrettyOptions(enum.Enum):
STDOUT_TTY_ONLY = enum.auto()


PRETTY_MAP = {
'all': ['format', 'colors'],
'colors': ['colors'],
'format': ['format'],
'none': []
}
PRETTY_STDOUT_TTY_ONLY = object()
PRETTY_STDOUT_TTY_ONLY = PrettyOptions.STDOUT_TTY_ONLY


DEFAULT_FORMAT_OPTIONS = [
Expand Down
Loading

0 comments on commit 77af4c7

Please sign in to comment.