mirror of
https://github.com/httpie/cli.git
synced 2024-11-25 09:13:25 +01:00
ff6f1887b0
* 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
64 lines
2.0 KiB
Python
64 lines
2.0 KiB
Python
from httpie.cli.options import ParserSpec, Qualifiers
|
|
|
|
|
|
def test_parser_serialization():
|
|
small_parser = ParserSpec("test_parser")
|
|
|
|
group_1 = small_parser.add_group("group_1")
|
|
group_1.add_argument("regular_arg", help="regular arg", short_help="short")
|
|
group_1.add_argument(
|
|
"variadic_arg",
|
|
metavar="META",
|
|
help=Qualifiers.SUPPRESS,
|
|
nargs=Qualifiers.ZERO_OR_MORE
|
|
)
|
|
group_1.add_argument(
|
|
"-O",
|
|
"--opt-arg",
|
|
action="lazy_choices",
|
|
getter=lambda: ["opt_1", "opt_2"],
|
|
help_formatter=lambda state, *, isolation_mode: ", ".join(state),
|
|
short_help="short_help",
|
|
)
|
|
|
|
group_2 = small_parser.add_group("group_2")
|
|
group_2.add_argument("--typed", action="store_true", type=int)
|
|
|
|
definition = small_parser.finalize()
|
|
assert definition.serialize() == {
|
|
"name": "test_parser",
|
|
"description": None,
|
|
"groups": [
|
|
{
|
|
"name": "group_1",
|
|
"description": None,
|
|
"is_mutually_exclusive": False,
|
|
"args": [
|
|
{
|
|
"options": ["regular_arg"],
|
|
"description": "regular arg",
|
|
"short_description": "short",
|
|
},
|
|
{
|
|
"options": ["variadic_arg"],
|
|
"is_optional": True,
|
|
"is_variadic": True,
|
|
"metavar": "META",
|
|
},
|
|
{
|
|
"options": ["-O", "--opt-arg"],
|
|
"description": "opt_1, opt_2",
|
|
"short_description": "short_help",
|
|
"choices": ["opt_1", "opt_2"],
|
|
},
|
|
],
|
|
},
|
|
{
|
|
"name": "group_2",
|
|
"description": None,
|
|
"is_mutually_exclusive": False,
|
|
"args": [{"options": ["--typed"], "python_type_name": "int"}],
|
|
},
|
|
],
|
|
}
|