andywerner/yaml_cli

How to edit subkey of a list item

Opened this issue · 0 comments

Given a file like

$ cat example.yaml
foo:
  - name: bar
  - name: baz
  - name: bat

I'd like to output

foo:
  - name: bar
  - name: quux
  - name: bat

Is there a way to index into a specific index in a list and a set a subkey while leaving all other subkeys and list item peers unchanged?

$ yaml_cli -i example.yaml -s foo:1:name quux
foo:
  '1':
    name: quux
$ yaml_cli -i example.yaml -s foo[1]:name quux
foo:
- name: bar
- name: baz
- name: bat
foo[1]:
  name: quux