google / yamlfmt

An extensible command line tool or library to format yaml files.
Apache License 2.0
1.2k stars 48 forks source link

Getting error: flag provided but not defined: -print_conf #187

Closed corneliusroemer closed 5 months ago

corneliusroemer commented 5 months ago

Per the documentation https://github.com/google/yamlfmt/edit/main/docs/command-usage.md I should be able to run yamlfmt -print_conf

But when I run this on version 0.12.0 I get an error:

yamlfmt -print_conf
flag provided but not defined: -print_conf
yamlfmt is a simple command line tool for formatting yaml files.

        Arguments:

        Glob paths to yaml files
                        Send any number of paths to yaml files specified in doublestar glob format (see: https://github.com/bmatcuk/doublestar).
                        Any flags must be specified before the paths.

        - or /dev/stdin
                        Passing in a single - or /dev/stdin will read the yaml from stdin and output the formatted result to stdout

        Flags:
  -conf string
        Read yamlfmt config from this path
  -continue_on_error
        Continue to format files that didn't fail instead of exiting with code 1.
  -debug value
        Debug codes to activate for debug logging
  -dry
        Perform a dry run; show the output of a formatting
        operation without performing it.
  -dstar
        Use doublestar globs for include and exclude
  -exclude value
        Paths to exclude in the chosen format (standard or doublestar)
  -extensions value
        File extensions to use for standard path collection
  -formatter value
        Config value overrides to pass to the formatter
  -gitignore_excludes
        Use a gitignore file for excludes
  -gitignore_path string
        Path to gitignore file to use (default ".gitignore")
  -global_conf
        Use global yamlfmt config from XDG_CONFIG_HOME
  -in
        Format yaml read from stdin and output to stdout
  -lint
        Check if there are any differences between
        source yaml and formatted yaml.
  -no_global_conf
        Disabled usage of global yamlfmt config from XDG_CONFIG_HOME
  -output_format string
        The engine output format (default "default")
  -quiet
        Print minimal output to stdout
  -version
        Print yamlfmt version

I'm using the homebrew installed version on an M1 running macOS 14.5. But the go compiled one has the same issue.

braydonk commented 5 months ago

I think -print_conf is a currently unreleased feature (I haven't cut a release in a while). I just compiled and tried it on the latest commit and it seems to work:

braydonk@braydonk:~/Git/yamlfmt_upstream$ ./yamlfmt -print_conf
continue_on_error: false
doublestar: false
exclude: []
extensions:
    - yaml
    - yml
gitignore_excludes: false
gitignore_path: .gitignore
include: []
line_ending: lf
output_format: default
regex_exclude: []
formatter:
    disallow_anchors: false
    drop_merge_tag: false
    include_document_start: false
    indent: 2
    indentless_arrays: false
    line_ending: lf
    max_line_length: 0
    pad_line_comments: 1
    retain_line_breaks: false
    retain_line_breaks_single: false
    scan_folded_as_literal: false
    type: basic

So if you have Go installed and are able, then the feature should be available if you do go install github.com/google/yamlfmt@main.

Not sure when the next release will be at the moment, I have one other thing I wanted to get done but not much time to do it. If I don't think I'll be able to fit in the other fix I was going to do I'll release soon.

braydonk commented 5 months ago

This is released in v0.13.0!