feat(cli): add `-f`/`-t`; hide `-if`/`-of` in help

`-f`/`--from` and `-t`/`--to` copy Pandoc and iconv(1).

`-if` and `-of` (with a single dash) are legacy options
from the Go days of Remarshal.
They are long overdue for hiding.
This commit is contained in:
D. Bohdan 2023-09-25 17:27:57 +00:00
parent c1b2ef082c
commit c08bf7636e
3 changed files with 22 additions and 6 deletions

View File

@ -74,7 +74,7 @@ options:
-v, --version show program's version number and exit
-i input, --input input
input file
--if {cbor,json,msgpack,toml,yaml}, -if {cbor,json,msgpack,toml,yaml}, --input-format {cbor,json,msgpack,toml,yaml}
--if {cbor,json,msgpack,toml,yaml}, --input-format {cbor,json,msgpack,toml,yaml}, -f {cbor,json,msgpack,toml,yaml}, --from {cbor,json,msgpack,toml,yaml}
input format
--json-indent n, --indent-json n
JSON indentation
@ -84,7 +84,7 @@ options:
1000000, negative for unlimited)
-o output, --output output
output file
--of {cbor,json,msgpack,toml,yaml}, -of {cbor,json,msgpack,toml,yaml}, --output-format {cbor,json,msgpack,toml,yaml}
--of {cbor,json,msgpack,toml,yaml}, --output-format {cbor,json,msgpack,toml,yaml}, -t {cbor,json,msgpack,toml,yaml}, --to {cbor,json,msgpack,toml,yaml}
output format
-s, --sort-keys sort JSON, TOML, YAML keys instead of preserving key
order

View File

@ -118,13 +118,21 @@ def _parse_command_line(argv: List[str]) -> argparse.Namespace: # noqa: C901.
if not format_from_argv0:
parser.add_argument(
"--if",
"-if",
"--input-format",
"-f",
"--from",
dest="input_format",
default="",
help="input format",
choices=FORMATS,
)
parser.add_argument(
"-if",
dest="input_format",
default="",
help=argparse.SUPPRESS,
choices=FORMATS,
)
if not format_from_argv0 or argv0_to == "json":
parser.add_argument(
@ -175,13 +183,21 @@ def _parse_command_line(argv: List[str]) -> argparse.Namespace: # noqa: C901.
if not format_from_argv0:
parser.add_argument(
"--of",
"-of",
"--output-format",
"-t",
"--to",
dest="output_format",
default="",
help="output format",
choices=FORMATS,
)
parser.add_argument(
"-of",
dest="output_format",
default="",
help=argparse.SUPPRESS,
choices=FORMATS,
)
parser.add_argument(
"-p",

View File

@ -461,9 +461,9 @@ class TestRemarshal(unittest.TestCase):
def test_run_no_input_file(self) -> None:
argv = [
sys.argv[0],
"-if",
"--from",
"json",
"-of",
"--to",
"json",
"fake-input-file-that-almost-certainly-doesnt-exist-2382",
]