Skip to main content

yamlfmt

A simple opionated yaml formatter that keeps your comments!

yamlfmt is just a cli wrapper around the ruamel.yaml python library, which happens to have the unique quality of keeping comments.

Usage

Note: The formatting used is subject to change without notice. Once a format seems to stick v1.0 will be tagged and the format will not change.

 yamlfmt -h
usage: yamlfmt [-h] [-w] [file [file ...]]

positional arguments:
  file         file to parse

optional arguments:
  -h, --help   show this help message and exit
  -w, --write  write formatted outpout to (source) file instead of stdout

Examples

Lets see yamlfmt in action:

Simple example from ruamel.yaml docs

 yamlfmt <<EOF
# example
name:
  # details
  family: Smith   # very common
  given: Alice    # one of the siblings
EOF
# example
name:
  # details
  family: Smith   # very common
  given: Alice    # one of the siblings

Travis-CI nodejs example

 yamlfmt <<EOF
language: node_js

# test on two node.js versions: 0.6 and 0.8
node_js:
  - 0.6
  - 0.8

# configure notifications (email, IRC, campfire etc)
# please update this section to your needs!
notifications:
  irc: "irc.freenode.org#travis"
EOF
language: node_js

# test on two node.js versions: 0.6 and 0.8
node_js:
- 0.6
- 0.8

# configure notifications (email, IRC, campfire etc)
# please update this section to your needs!
notifications:
  irc: irc.freenode.org#travis

Complex example from ruamel.yaml docs

 yamlfmt <<EOF
- &CENTER {x: 1, y: 2}
- &LEFT {x: 0, y: 2}
- &BIG {r: 10}
- &SMALL {r: 1}
# All the following maps are equal:
# Explicit keys
- x: 1
  y: 2
  r: 10
  label: center/big
# Merge one map
- <<: *CENTER
  r: 10
  label: center/big
# Merge multiple maps
- <<: [*CENTER, *BIG]
  label: center/big
# Override
- <<: [*BIG, *LEFT, *SMALL]
  x: 1
  label: center/big
EOF
- &CENTER {x: 1, y: 2}
- &LEFT {x: 0, y: 2}
- &BIG {r: 10}
- &SMALL {r: 1}
# All the following maps are equal:
# Explicit keys
- x: 1
  y: 2
  r: 10
  label: center/big
# Merge one map
- <<: *CENTER
  r: 10
  label: center/big
# Merge multiple maps
- <<: [*CENTER, *BIG]
  label: center/big
# Override
- <<: [*BIG, *LEFT, *SMALL]
  x: 1
  label: center/big

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yamlfmt-0.1.7.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yamlfmt-0.1.7-py2.py3-none-any.whl (8.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file yamlfmt-0.1.7.tar.gz.

File metadata

  • Download URL: yamlfmt-0.1.7.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for yamlfmt-0.1.7.tar.gz
Algorithm Hash digest
SHA256 5ccd869762c815c000c394a0ee233095b57e34d9ee0f5e291fbeaed5342f7edc
MD5 8b96b4d5119bfb80193e96bf2266e105
BLAKE2b-256 50494797c1282f5f07230713825d774cc20c0f06bfef799b26af95cf8dcecb70

See more details on using hashes here.

File details

Details for the file yamlfmt-0.1.7-py2.py3-none-any.whl.

File metadata

  • Download URL: yamlfmt-0.1.7-py2.py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for yamlfmt-0.1.7-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 183cf907307191e13f2e859b92d4e42d507e4c66a34880078301409132f7a7c8
MD5 bad23110db64096c9f978390382ee457
BLAKE2b-256 dce73d384c94929c31832ec13bb017a8af38d7ae467f8a4b14140ece5cb2d5a7

See more details on using hashes here.

Release history Release notifications | RSS feed

1.1.1

1 file

1.1.0

2 files

1.0.0

2 files

This release

0.1.7 This release

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

1 file

0.1.3

1 file

0.1.2

1 file

0.1.1

1 file

0.1

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page