1
0
mirror of https://github.com/httpie/cli.git synced 2025-08-10 22:42:05 +02:00

[Major] UI Enhancements (#1321)

* Refactor tests to use a text-based standard output. (#1318)

* Implement new style `--help` (#1316)

* Implement man page generation (#1317)

* Implement rich progress bars. (#1324)

* Man page deployment & isolation. (#1325)

* Remove all unsorted usages in the CLI docs

* Implement isolated mode for man page generation

* Add a CI job for autogenerated files

* Distribute man pages through PyPI

* Pin the date for man pages. (#1326)

* Hide suppressed arguments from --help/man pages (#1329)

* Change download spinner to line (#1328)

* Regenerate autogenerated files when pushed against to master. (#1339)

* Highlight options (#1340)

* Additional man page enhancements (#1341)

* Group options by the parent category & highlight -o/--o

* Display (and underline) the METAVAR on man pages.

* Make help message processing more robust (#1342)

* Inherit `help` from `short_help`

* Don't mirror short_help directly.

* Fixup the serialization

* Use `pager` and `man` on `--manual` when applicable (#1343)

* Run `man $program` on --manual

* Page the output of `--manual` for systems that lack man pages

* Improvements over progress bars (separate bar, status line, etc.) (#1346)

* Redesign the --help layout.

* Make our usage of rich compatible with 9.10.0

* Add `HTTPIE_NO_MAN_PAGES`

* Make tests also patch os.get_terminal_size

* Generate CLI spec from HTTPie & Man Page Hook (#1354)

* Generate CLI spec from HTTPie & add man page hook

* Use the full command space for the option headers
This commit is contained in:
Batuhan Taskaya
2022-04-14 17:43:10 +03:00
committed by GitHub
parent 86f4bf4d0a
commit ff6f1887b0
32 changed files with 2521 additions and 389 deletions

View File

@@ -1,5 +1,6 @@
from textwrap import dedent
from httpie.cli.argparser import HTTPieManagerArgumentParser
from httpie.cli.options import Qualifiers, ARGPARSE_QUALIFIER_MAP, map_qualifiers, parser_to_parser_spec
from httpie import __version__
CLI_SESSION_UPGRADE_FLAGS = [
@@ -58,7 +59,8 @@ COMMANDS['plugins'] = COMMANDS['cli']['plugins'] = {
'or from a local paths.',
{
'dest': 'targets',
'nargs': '+',
'metavar': 'TARGET',
'nargs': Qualifiers.ONE_OR_MORE,
'help': 'targets to install'
}
],
@@ -66,7 +68,8 @@ COMMANDS['plugins'] = COMMANDS['cli']['plugins'] = {
'Upgrade the given plugins',
{
'dest': 'targets',
'nargs': '+',
'metavar': 'TARGET',
'nargs': Qualifiers.ONE_OR_MORE,
'help': 'targets to upgrade'
}
],
@@ -74,7 +77,8 @@ COMMANDS['plugins'] = COMMANDS['cli']['plugins'] = {
'Uninstall the given HTTPie plugins.',
{
'dest': 'targets',
'nargs': '+',
'metavar': 'TARGET',
'nargs': Qualifiers.ONE_OR_MORE,
'help': 'targets to install'
}
],
@@ -94,7 +98,7 @@ def missing_subcommand(*args) -> str:
return f'Please specify one of these: {subcommands}'
def generate_subparsers(root, parent_parser, definitions):
def generate_subparsers(root, parent_parser, definitions, spec):
action_dest = '_'.join(parent_parser.prog.split()[1:] + ['action'])
actions = parent_parser.add_subparsers(
dest=action_dest
@@ -107,13 +111,15 @@ def generate_subparsers(root, parent_parser, definitions):
command_parser = actions.add_parser(command, description=descr)
command_parser.root = root
if is_subparser:
generate_subparsers(root, command_parser, properties)
generate_subparsers(root, command_parser, properties, spec)
continue
group = spec.add_group(parent_parser.prog + ' ' + command, description=descr)
for argument in properties:
argument = argument.copy()
flags = argument.pop('flags', [])
command_parser.add_argument(*flags, **argument)
command_parser.add_argument(*flags, **map_qualifiers(argument, ARGPARSE_QUALIFIER_MAP))
group.add_argument(*flags, **argument)
parser = HTTPieManagerArgumentParser(
@@ -160,4 +166,5 @@ parser.add_argument(
'''
)
generate_subparsers(parser, parser, COMMANDS)
options = parser_to_parser_spec(parser)
generate_subparsers(parser, parser, COMMANDS, options)