Skip to content

Commit 77af4c7

Browse files
authored
Decouple parser definition from argparse (#1293)
1 parent 7509dd4 commit 77af4c7

File tree

12 files changed

+711
-297
lines changed

12 files changed

+711
-297
lines changed

docs/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2402,6 +2402,27 @@ For managing these plugins; starting with 3.0, we are offering a new plugin mana
24022402
24032403
This command is currently in beta.
24042404
2405+
### `httpie cli`
2406+
2407+
#### `httpie cli export-args`
2408+
2409+
`httpie cli export-args` command can expose the parser specification of `http`/`https` commands
2410+
(like an API definition) to outside tools so that they can use this to build better interactions
2411+
over them (e.g offer auto-complete).
2412+
2413+
2414+
Available formats to export in include:
2415+
| format | Description |
2416+
|--------|---------------------------------------------------------------------------------------------------------------------------------------------------|
2417+
| `json` | Export the parser spec in JSON. The schema includes a top-level `version` parameter which should be interpreted in [semver](https://semver.org/). |
2418+
2419+
You can use any of these formats with `--format` parameter, but the default one is `json`.
2420+
2421+
```bash
2422+
$ httpie cli export-args | jq '"Program: " + .spec.name + ", Version: " + .version'
2423+
"Program: http, Version: 0.0.1a0"
2424+
```
2425+
24052426
### `httpie plugins`
24062427
24072428
`plugins` interface is a very simple plugin manager for installing, listing and uninstalling HTTPie plugins.

httpie/cli/constants.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,19 @@
9090
})
9191

9292
# Pretty
93+
94+
95+
class PrettyOptions(enum.Enum):
96+
STDOUT_TTY_ONLY = enum.auto()
97+
98+
9399
PRETTY_MAP = {
94100
'all': ['format', 'colors'],
95101
'colors': ['colors'],
96102
'format': ['format'],
97103
'none': []
98104
}
99-
PRETTY_STDOUT_TTY_ONLY = object()
105+
PRETTY_STDOUT_TTY_ONLY = PrettyOptions.STDOUT_TTY_ONLY
100106

101107

102108
DEFAULT_FORMAT_OPTIONS = [

0 commit comments

Comments
 (0)