Code Monkey home page Code Monkey logo

hclfmt's People

Contributors

chiefy avatar chrw avatar fatih avatar fgrehm avatar julienvey 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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

hclfmt's Issues

hclfmt on a range?

Hey @fatih,

Love the project and all the work you do in general. Was wondering if you'd be open to having hclfmt work on a range?

I have a project with some string literals that contain HCL and they are not formatted nicely (but I want them to be).

Cheers

Multiple comment lines split by newlines

Maybe this is desired behavior, but currently hclfmt converts this:

### comment line one
### comment line two
provider "aws" {
  foo = "bar"
}

as:

### comment line one

### comment line two
provider "aws" {
  foo = "bar"
}

It correctly (IMO) keeps the second comment directly above the provider object, but otherwise splits the comments.

I know multiline comments can be created with /**/, but the current behavior still seems odd.

Add quiet / exit code option

I'd like to use hclfmt to ensure my files are correctly formatted before committing changes to my repo. It would be nice if hclfmt would have an option which simply checks if a file has "incorrect" formatting and exits 1 if so (0 if everything is fine). eg hclfmt -q main.tf

Currently I can work around this issue by diffing the output against the source file, but this is a little painful.

Multiline comments get a blank line in-between.

    # Priority controls our access to resources and scheduling priority.
    # This can be 1 to 100, inclusively, and defaults to 50.
    # priority = 50

becomes:

  # Priority controls our access to resources and scheduling priority.


  # This can be 1 to 100, inclusively, and defaults to 50.


  # priority = 50

Releases

Hi Faith,

Could you please do a build for linux (amd64) and update a release so that we all need not build the binary locally and can refer to the releases? If you can give me permission, I can upload a release too.

-Renjith

Prefer one line variable declarations

Hello! I really like this project and the parser you wrote. It's been helpful for me to understand Go, being only exposed to it through Terraform code base up until now. I have one issue with how you're currently doing the formatting, and I was wondering if this was configurable or not. Here's the issue:

The standard convention when defining terraform variables is to do it similar to this:

# empty variable -- always written on 1 line
variable simple_string_empty { }

# variable with default string parameter -- always written on 1 line
variable simple_string_default { default = "value" }

# example complex variable, written on multiple lines (Maps and Lists)
variable complex_map { 
    default = {
        key1 = "val1"
        key2 = "val2"
    }
}

My question is about the simple variables. When writing a terraform config, it's common to have several, or even 10-20+ of them in a single file. Since these are basically "boiler plate", we want them as terse as possible. The formatter currently outputs these simple variables like this:

# empty variable -- always written on 1 line
variable simple_string_empty {
}

# variable with default string parameter -- always written on 1 line
variable simple_string_default { 
    default = "/dev/sdh" 
}

For empty variables, this increase the LOC in a file 2x, and for simple variables with a default, it increases it by 3x. I spent some time looking at the parser, to see if there were some configurations options that might be set, but didn't have much luck. Is there any way your parser could generically differentiate between simple and complex types, and print them differently?

I don't even necessarily need you to implement this feature if this is not a priority, but if you could confirm that this should be possible, and pick out the relevant section of the codebase, I'd be happy to take a crack at it myself.

TL;DR; -- Love the formatter mostly, but it's blowing up my variable definitions and making it hard to read. Can you fix, or show me where I can fix?

Empty block formatting

Currently, hclfmt doesn't seem to allow the following formatting:

variable "foobar" {}

Instead, this will be changed to:

variable "foobar" {
}

This seems odd to me and I'm not sure if this is intentional.

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.