Skip to content

Text YAML

Vali (naser) Rafinia edited this page Mar 27, 2023 · 4 revisions

nhash text yaml is a sub-command of nhash that allows the user to perform various operations on YAML text, such as parsing, formatting, and converting to other formats.

Usage

nhash text yaml [<text>] [options]

Arguments

  • <text>: Optional. The YAML text to be processed.

Options

  • -f, --file <file>: The name of a file to read the YAML text from.
  • -c, --convert <JSON|XML|YAML>: Convert the YAML text to the specified format (JSON, XML).
  • -o, --output <output>: The name of a file to write the output to.
  • -?, -h, --help: Show help and usage information.

Examples

  1. To parse YAML text, simply provide the YAML text as an argument:
nhash text yaml 'name: John Doe
age: 30'

Output:

name: John Doe
age: 30
  1. To read YAML text from a file, use the -f or --file option:
nhash text yaml -f input.yaml
  1. To convert YAML text to JSON, use the --convert JSON option:
nhash text yaml 'name: John Doe
age: 30' -c json

Output:

{
  "name": "John Doe",
  "age": 30
}
  1. To write the output to a file, use the --output option:
nhash text yaml 'name: John Doe
age: 30' -c JSON --output output.json

The output will be written to output.json.