grasmash/yaml-cli

A command line tool for reading and manipulating yaml files.

Maintainers

👁 grasmash

Package info

github.com/grasmash/yaml-cli

pkg:composer/grasmash/yaml-cli

Statistics

Installs: 26 057 417

Dependents: 10

Suggesters: 0

Stars: 25

Open Issues: 4

3.2.1 2024-04-23 02:10 UTC

Requires

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT 09a8860566958a1576cc54bbe910a03477e54971

  • Matthew Grasmick

README

👁 CI
👁 Packagist
👁 Total Downloads
👁 Coverage Status

Yet another command line tool for reading and manipulating yaml files, built on the Symfony console component.

Commands:

Command Description
get:value Get a value for a specific key in a YAML file.
get:type Get the data type of a value in a YAML file.
lint Validates that a given YAML file has valid syntax.
unset:key Unset a specific key in a YAML file.
update:key Change a specific key in a YAML file.
update:value Update the value for a specific key in a YAML file.

Installation

composer require grasmash/yaml-cli

Example usage:

./vendor/bin/yaml-cli get:value somefile.yml some-key
./vendor/bin/yaml-cli get:type somefile.yml some-key
./vendor/bin/yaml-cli lint somefile.yml
./vendor/bin/yaml-cli unset:value somefile.yml some-key
./vendor/bin/yaml-cli update:key somefile.yml old-key new-key
./vendor/bin/yaml-cli update:value somefile.yml some-key some-value

# Cast to boolean.
./vendor/bin/yaml-cli update:value somefile.yml some-key false
./vendor/bin/yaml-cli update:value somefile.yml some-key true
./vendor/bin/yaml-cli update:value somefile.yml some-key 0 --type=boolean
./vendor/bin/yaml-cli update:value somefile.yml some-key 0 --type=bool

# Cast to null.
./vendor/bin/yaml-cli update:value somefile.yml some-key null
./vendor/bin/yaml-cli update:value somefile.yml some-key ~ --type=null

# Cast to integer.
./vendor/bin/yaml-cli update:value somefile.yml some-key 1 --type=integer
./vendor/bin/yaml-cli update:value somefile.yml some-key 1 --type=int

# Cast to float/double/real.
./vendor/bin/yaml-cli update:value somefile.yml some-key 1.0 --type=float
./vendor/bin/yaml-cli update:value somefile.yml some-key 1.0 --type=double
./vendor/bin/yaml-cli update:value somefile.yml some-key 1.0 --type=real

# Forcibly cast to string for values that would otherwise be boolean or null.
./vendor/bin/yaml-cli update:value somefile.yml some-key true --type=string
./vendor/bin/yaml-cli update:value somefile.yml some-key false --type=string
./vendor/bin/yaml-cli update:value somefile.yml some-key null --type=string

Similar tools:

Recognition

This project was inspired by the yaml commands in Drupal Console.