NAME

ymask - Mask a data structure to display only the desired fields

VERSION

version 0.032

SYNOPSIS

ymask <mask> [<file>...]

ymask -h|--help|--version

DESCRIPTION

This program takes a stream of YAML documents (on STDIN or file arguments), and prints only the fields specified by the mask.

ARGUMENTS

mask

See MASK SYNTAX for more information

<file>

A YAML file to read. The special file "-" refers to STDIN. If no files are specified, read STDIN.

OPTIONS

-h | --help

Show this help document.

--version

Print the current ymask and Perl versions.

MASK SYNTAX

PROPERTIES

$ ymask 'name,rank,serial'

Select multiple properties in a document using ,. If a property does not exist, nothing will be added (and no error or warning will be output).

DESCENDANTS

$ ymask 'squad/name'

Select an inner document's properties using /. Arrays are automatically looped over.

SUB-SELECTION

$ ymask 'squad(name,location)'

Select multiple parts of an inner document by using parentheses.

WILDCARDS

$ ymask 'squad/*/city'

Select every property in a document, which is useful for picking parts out of every inner document.

EXAMPLES

All these examples use the following documents:

---
name: Hazel Murphy
role: Captain
nickname: Hank
history:
    - location: Sealab
      from: 2014-01-01
    - location: USS Hunley
      from: 2012-06-01
      to: 2013-11-28
---
name: Quinn Quinlan
role: Science Officer
nickname: Doctor
history:
    - location: Sealab
      from: 2014-04-01
    - location: MIT
      from: 2008-08-01
      to: 2012-06-05
---
name: Debbie Dupree
role: Oceanographer
history:
    - location: Sealab
      from: 2014-02-10
    - location: Sea Parks
      from: 2004-09-01
      to: 2014-01-20

SELECT MULTIPLE PROPERTIES

$ ymask 'name,role,nickname'
---
name: Hazel Murphy
nickname: Hank
role: Captain
---
name: Quinn Quinlan
nickname: Doctor
role: Science Officer
---
name: Debbie Dupree
role: Oceanographer

SELECT PROPERTIES IN ARRAYS

$ ymask 'name,history/location'
---
history:
  - location: Sealab
  - location: USS Hunley
name: Hazel Murphy
---
history:
  - location: Sealab
  - location: MIT
name: Quinn Quinlan
---
history:
  - location: Sealab
  - location: Sea Parks
name: Debbie Dupree

ENVIRONMENT VARIABLES

YERTL_FORMAT

Specify the default format Yertl uses between commands. Defaults to yaml. Can be set to json for interoperability with other programs.

SEE ALSO

AUTHOR

Doug Bell <preaction@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2016 by Doug Bell.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.