项目作者: shin1x1

项目描述 :
YAML aliases expander
高级语言: Go
项目地址: git://github.com/shin1x1/yae.git
创建时间: 2019-05-16T14:25:53Z
项目社区:https://github.com/shin1x1/yae

开源协议:MIT License

下载


yae - YAML aliases expander

Build Status

yae is a YAML aliases expander, written by Go.

Motivation

When refactoring a long YAML using anchor/alias, I created it to make sure that the original YAML and the refactored YAML are identical.

By comparing the original YAML with the refactored YAML output from the yae command with diff, you can verify that the contents of YAML have not changed.

  1. $ diff <(yae original.yaml) <(yae refactored.yaml)

Since the yae command can change the indentation of the list, the sequence of keys, and other parts that are not relevant to the meaning of YAML, the original YAML uses this command to ensure that the diff command does not cause differences in formatting.

Installation

Download binary from below link.

https://github.com/shin1x1/yae/releases

You can install using go get.

  1. go get -u github.com/shin1x1/yae

Usage

Run the yae command with the YAML file path that you want to expand alias as an argument.

  1. $ cat original.yaml
  2. ---
  3. anchors:
  4. items:
  5. - &book # anchor
  6. name: book
  7. price: 100
  8. stocks:
  9. - *book # alias
  10. - <<: *book # alias with overwrite key
  11. price: 200
  12. $ yae src.yaml
  13. anchors:
  14. items:
  15. - name: book
  16. price: 100
  17. stocks:
  18. - name: book
  19. price: 100
  20. - name: book
  21. price: 200