0k / shyaml

YAML for command line
BSD 2-Clause "Simplified" License
767 stars 57 forks source link

shyaml requires at least one key to check for missing key #62

Open andrewv99 opened 3 years ago

andrewv99 commented 3 years ago

Version: shyaml 0.6.1

cat <<EOF > test1.yaml
# a:
EOF

shyaml get-value a '' < test1.yaml
Error: invalid path 'a', can't query subvalue 'a' of a leaf (leaf value is None).

cat <<EOF > test2.yaml
# a:
b: 1
EOF

shyaml get-value a '' < test2.yaml

# (empty output -> no error)

I would expect test1.yaml with no keys to be able to be queried for a non existent key, when supplying a default value, and return an empty result - not an error. It appears the document must have at least one key defined for the test to be successful.