Skip to content

Commit 9536e6b

Browse files
committed
Document explicit start/end options
1 parent e95fc2f commit 9536e6b

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

README.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ yq can be called as a module if needed. With ``-y/-Y``, files can be edited in p
3838

3939
python -m yq -Y --indentless --in-place '.["current-context"] = "staging-cluster"' ~/.kube/config
4040

41-
Use the ``--width``/``-w`` option to pass the line wrap width for string literals. All other command line arguments are
42-
forwarded to ``jq``. ``yq`` forwards the exit code ``jq`` produced, unless there was an error in YAML parsing, in which
43-
case the exit code is 1. See the `jq manual <https://stedolan.github.io/jq/manual/>`_ for more details on ``jq``
44-
features and options.
41+
Use the ``--width``/``-w`` option to pass the line wrap width for string literals. Use
42+
``--explicit-start``/``--explicit-end`` to emit YAML start/end markers even when processing a single document. All other
43+
command line arguments are forwarded to ``jq``. ``yq`` forwards the exit code ``jq`` produced, unless there was an error
44+
in YAML parsing, in which case the exit code is 1. See the `jq manual <https://stedolan.github.io/jq/manual/>`_ for more
45+
details on ``jq`` features and options.
4546

4647
Because YAML treats JSON as a dialect of YAML, you can use yq to convert JSON to YAML: ``yq -y . < in.json > out.yml``.
4748

yq/parser.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def print_help(self):
3838
def get_parser(program_name, description):
3939
# By default suppress these help strings and only enable them in the specific programs.
4040
yaml_output_help, yaml_roundtrip_help, width_help, indentless_help, grammar_help = [argparse.SUPPRESS] * 5
41+
explicit_start_help, explicit_end_help = [argparse.SUPPRESS] * 2
4142
xml_output_help, xml_item_depth_help, xml_dtd_help, xml_root_help, xml_force_list_help = [argparse.SUPPRESS] * 5
4243
toml_output_help = argparse.SUPPRESS
4344

@@ -57,6 +58,8 @@ def get_parser(program_name, description):
5758
"to 1.2 in a future version). Setting this to 1.2 will cause strings like 'on' and 'no' to be "
5859
"emitted unquoted."
5960
)
61+
explicit_start_help = 'When using --yaml-output, always emit explicit document start ("---")'
62+
explicit_end_help = 'When using --yaml-output, always emit explicit document end ("...")'
6063
elif program_name == "xq":
6164
current_language = "XML"
6265
xml_output_help = "Transcode jq JSON output back into XML and emit it"
@@ -99,8 +102,8 @@ def get_parser(program_name, description):
99102
)
100103
parser.add_argument("--width", "-w", type=int, help=width_help)
101104
parser.add_argument("--indentless-lists", "--indentless", action="store_true", help=indentless_help)
102-
parser.add_argument("--explicit-start", action="store_true", help=argparse.SUPPRESS)
103-
parser.add_argument("--explicit-end", action="store_true", help=argparse.SUPPRESS)
105+
parser.add_argument("--explicit-start", action="store_true", help=explicit_start_help)
106+
parser.add_argument("--explicit-end", action="store_true", help=explicit_end_help)
104107
parser.add_argument("--no-expand-aliases", action="store_false", dest="expand_aliases", help=argparse.SUPPRESS)
105108
parser.add_argument("--max-expansion-factor", type=int, default=1024, help=argparse.SUPPRESS)
106109
parser.add_argument(

0 commit comments

Comments
 (0)