summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Kislyuk <kislyuk@gmail.com>2018-08-03 19:55:16 -0700
committerAndrey Kislyuk <kislyuk@gmail.com>2018-08-03 19:55:16 -0700
commite06d7a585d8700d69882677c30f9ad65d354786e (patch)
tree85c2de55849b0a13dfbf7168daf0bf4a4c6a751e
parentaac298c80164b95cb234dab923cdf7a01ad8481b (diff)
Disallow argparse abbreviated options. Fixes #38 on Python 3.
-rwxr-xr-xyq/__init__.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/yq/__init__.py b/yq/__init__.py
index 2d24962..e8ff814 100755
--- a/yq/__init__.py
+++ b/yq/__init__.py
@@ -92,8 +92,10 @@ def get_parser(program_name):
raise Exception("Unknown program name")
description = __doc__.replace("yq", program_name).replace("YAML", replace_yaml)
-
- parser = Parser(prog=program_name, description=description, formatter_class=argparse.RawTextHelpFormatter)
+ parser_args = dict(prog=program_name, description=description, formatter_class=argparse.RawTextHelpFormatter)
+ if not USING_PYTHON2:
+ parser_args.update(allow_abbrev=False) # required to disambiguate options listed in jq_arg_spec
+ parser = Parser(**parser_args)
parser.add_argument("--yaml-output", "--yml-output", "-y", action="store_true", help=yaml_output_help)
parser.add_argument("--width", "-w", type=int, help=width_help)
parser.add_argument("--xml-output", "-x", action="store_true", help=xml_output_help)