Giter VIP home page Giter VIP logo

yamlfmt's Introduction

YAMLFMT

Go Report Card Go Reference

A simple and extensible yaml formatter.

Installation

go install github.com/UltiRequiem/yamlfmt@latest

You can also use the binaries from releases.

Usage

  • To format one or more files and write to stdout:

    yamlfmt a.yaml b.yaml c.yaml
  • To format one or more files in the replace mode:

    yamlfmt -w a.yaml b.yaml c.yaml

    If you want to log the files that have been formatted, you can use the -l flag also.

  • To format stdin and write to stdout:

    cat a.yaml | yamlfmt
  • To format stdin and write to a file:

    cat a.yaml | yamlfmt > b.yaml
  • To format every file in your current directory and subdirectories:

    • Using find:

      yamlfmt -w $(find -name "*.yaml")
    • Using fd:

      yamlfmt -w $(fd -H -e yaml)

Editor Integration

Neovim / Vim

au FileType yaml let &l:formatprg= "yamlfmt /dev/stdin"

It can Probably integrate with others editors easily but I only use Neovim. If you know how to integrate it with some other editor, please open a pull requests or issue with the information.

Authors

Eliaz Bobadilla - Creator and Maintainer 💪

See also the full list of contributors who participated in this project ✨

Support

Open an Issue, I will check it a soon as possible 👀

If you want to hurry me up a bit send me a tweet 😆

Consider supporting me on Patreon if you like my work 🙏

Don't forget to star the repo ⭐

Licence

Licensed under the MIT License 📄

yamlfmt's People

Contributors

ultirequiem avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

yamlfmt's Issues

multiline scalar with trailing space will foramted to double qouted literal

be aware that there is a trailing space at the second echo line.

cat <<EOF | yamlfmt
foo: |
  #/usr/bin/bash
  # test
  echo "hello world"
  echo "this line end with a trailing space" 
EOF

actual result:

foo: "#/usr/bin/bash\n# test\necho \"hello world\"\necho \"this line end with a trailing space\" \n"

expected result:

foo: |
  #/usr/bin/bash
  # test
  echo "hello world"
  echo "this line end with a trailing space" 

but if remove the trainling space of echo "this line end with a trailing space" , things goes ok.

cat <<EOF | yamlfmt
foo: |
  #/usr/bin/bash
  # test
  echo "hello world"
  echo "this line end without a trailing space"
EOF

result:

foo: |
  #/usr/bin/bash
  # test
  echo "hello world"
  echo "this line end without a trailing space"

maybe it is an upstream issue.

Document pkg/

Currently, I'm not showing how to use it as a library.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.