mercari / hcledit

Go package to edit HCL configuration
MIT License
49 stars 15 forks source link

Add --comment flag to create subcommand #30

Closed micnncim closed 3 years ago

micnncim commented 3 years ago

WHAT

Added --comment|-c flag to hclecit create.

$ go run ./cmd/hcledit/main.go create 'module.my-module.key' 'value' --comment '// Comment' ./cmd/hcledit/internal/command/fixture/file.tf

$ git --no-pager diff
diff --git a/cmd/hcledit/internal/command/fixture/file.tf b/cmd/hcledit/internal/command/fixture/file.tf
index 2d98c5c..7efd30b 100644
--- a/cmd/hcledit/internal/command/fixture/file.tf
+++ b/cmd/hcledit/internal/command/fixture/file.tf
@@ -29,4 +29,6 @@ module "my-module" {
       "f",
     ]
   }
+  // Comment
+  key = "value"
 }

WHY

From: https://github.com/mercari/hcledit/issues/6