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:
parent
c1b2ef082c
commit
c08bf7636e
|
@ -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
|
||||
|
|
20
remarshal.py
20
remarshal.py
|
@ -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",
|
||||
|
|
|
@ -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",
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue