Skip to content

How to edit subkey of a list item #2

@egoldblum

Description

@egoldblum

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions