yaml / yamlscript

Programming in YAML
MIT License
382 stars 31 forks source link

Preserve key order in YAML mapping output #121

Closed omythic closed 6 months ago

omythic commented 6 months ago

AFAIK clojure does not support preserving key order in its standard hash type. This is awkward for cases where one needs to preserve key order in output YAML -- can that be made possible?

ingydotnet commented 6 months ago

I've added a -O, --ordered Mappings preserve key order option. You can also use an environment variable:

$ ys --load --ordered --yaml file.ys
$ YS_ORDERED=1 ys --load --yaml file.ys

For now when using a binding like Python's you'll need to set the environment variable to get this behavior.

ingydotnet commented 6 months ago

@omythic

To test this PR:

git clone https://github.com/yaml/yamlscript
cd yamlscript
git checkout ingy/issue-121
make install
ys --help   # should show `--ordered`
omythic commented 6 months ago

That works for me @ingydotnet ! Awesome, thank you. Turned that around so fast.