github.com/google/yamlfmt@v0.12.2-0.20240514121411-7f77800e2681/README.md (about)

     1  # yamlfmt
     2  
     3  `yamlfmt` is an extensible command line tool or library to format yaml files. 
     4  
     5  ## Goals
     6  
     7  * Create a command line yaml formatting tool that is easy to distribute (single binary)
     8  * Make it simple to extend with new custom formatters
     9  * Enable alternative use as a library, providing a foundation for users to create a tool that meets specific needs 
    10  
    11  ## Maintainers
    12  
    13  This tool is not yet officially supported by Google. It is currently maintained solely by @braydonk, and unless something changes primarily in spare time.
    14  
    15  ## Blog
    16  
    17  I'm going to use these links to GitHub Discussions as a blog of sorts, until I can set up something more proper:
    18  * yamlfmt's recent slow development [#149](https://github.com/google/yamlfmt/discussions/149)
    19  * Issues related to the yaml.v3 library [#148](https://github.com/google/yamlfmt/discussions/148)
    20  
    21  ## Installation
    22  
    23  To download the `yamlfmt` command, you can download the desired binary from releases or install the module directly:
    24  ```
    25  go install github.com/google/yamlfmt/cmd/yamlfmt@latest
    26  ```
    27  This currently requires Go version 1.18 or greater.
    28  
    29  NOTE: Recommended setup if this is your first time installing Go would be in [this DigitalOcean blog post](https://www.digitalocean.com/community/tutorials/how-to-build-and-install-go-programs).
    30  
    31  You can also download the binary you want from releases. The binary is self-sufficient with no dependencies, and can simply be put somewhere on your PATH and run with the command `yamlfmt`.
    32  
    33  You can also install the command as a [pre-commit](https://pre-commit.com/) hook. See the [pre-commit hook](./docs/pre-commit.md) docs for instructions.
    34  
    35  ## Basic Usage
    36  
    37  See [Command Usage](./docs/command-usage.md) for in-depth information and available flags.
    38  
    39  To run the tool with all default settings, run the command with a path argument:
    40  ```bash
    41  yamlfmt x.yaml y.yaml <...>
    42  ```
    43  You can specify as many paths as you want. You can also specify a directory which will be searched recursively for any files with the extension `.yaml` or `.yml`.
    44  ```bash
    45  yamlfmt .
    46  ```
    47  
    48  You can also use an alternate mode that will search paths with doublestar globs by supplying the `-dstar` flag. 
    49  ```bash
    50  yamlfmt -dstar **/*.{yaml,yml}
    51  ```
    52  See the [doublestar](https://github.com/bmatcuk/doublestar) package for more information on this format.
    53  
    54  # Configuration File
    55  
    56  The `yamlfmt` command can be configured through a yaml file called `.yamlfmt`. This file can live in your working directory, a path specified through a [CLI flag](./docs/command-usage.md#operation-flags), or in the standard global config path on your system (see docs for specifics).
    57  For in-depth configuration documentation see [Config](docs/config-file.md).