{"id":13505805,"url":"https://github.com/minamijoyo/hcledit","last_synced_at":"2025-05-16T12:06:31.830Z","repository":{"id":37793918,"uuid":"231227654","full_name":"minamijoyo/hcledit","owner":"minamijoyo","description":"A command line editor for HCL","archived":false,"fork":false,"pushed_at":"2024-08-30T08:59:40.000Z","size":261,"stargazers_count":462,"open_issues_count":18,"forks_count":30,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-10-30T02:36:59.548Z","etag":null,"topics":["cli","go","hcl"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/minamijoyo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-01T14:42:28.000Z","updated_at":"2024-10-28T08:23:01.000Z","dependencies_parsed_at":"2024-01-03T02:28:42.690Z","dependency_job_id":"ea37ee04-48f4-42eb-98b9-ed862d15f982","html_url":"https://github.com/minamijoyo/hcledit","commit_stats":{"total_commits":202,"total_committers":9,"mean_commits":"22.444444444444443","dds":"0.044554455445544594","last_synced_commit":"cf25f07b69e6e636030c198848cbd88e5f3e3a12"},"previous_names":[],"tags_count":32,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minamijoyo%2Fhcledit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minamijoyo%2Fhcledit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minamijoyo%2Fhcledit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minamijoyo%2Fhcledit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/minamijoyo","download_url":"https://codeload.github.com/minamijoyo/hcledit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247987285,"owners_count":21028895,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","go","hcl"],"created_at":"2024-08-01T00:01:14.236Z","updated_at":"2025-04-09T06:09:14.731Z","avatar_url":"https://github.com/minamijoyo.png","language":"Go","funding_links":[],"categories":["Tools","Go"],"sub_categories":["Community providers"],"readme":"# hcledit\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)\n[![GitHub release](https://img.shields.io/github/release/minamijoyo/hcledit.svg)](https://github.com/minamijoyo/hcledit/releases/latest)\n[![GoDoc](https://godoc.org/github.com/minamijoyo/hcledit/hcledit?status.svg)](https://godoc.org/github.com/minamijoyo/hcledit)\n\n## Features\n\n- CLI-friendly: Read HCL from stdin, edit and write to stdout, easily pipe and combine other commands\n- Token-based edit: You can update lots of existing HCL files with automation scripts without losing comments.\n- Schemaless: No dependency on specific HCL application binary or schema\n- Support HCL2 (not HCL1)\n- Available operations:\n  - attribute append / get / mv / replace / rm / set\n  - block append / get / list / mv / new / rm\n  - body get\n  - fmt\n\nThe hcledit focuses on editing HCL with command line, doesn't aim for generic query tools. It was originally born for refactoring Terraform configurations, but it's not limited to specific applications.\nThe HCL specification is somewhat generic, so usability takes precedence over strictness if there is room for interpreting meanings in the schemaless approach.\n\n## Install\n\n### Homebrew\n\nIf you are macOS user:\n\n```\n$ brew install minamijoyo/hcledit/hcledit\n```\n\n### Download\n\nDownload the latest compiled binaries and put it anywhere in your executable path.\n\nhttps://github.com/minamijoyo/hcledit/releases\n\n### Source\n\nIf you have Go 1.23+ development environment:\n\n```\n$ git clone https://github.com/minamijoyo/hcledit\n$ cd hcledit/\n$ make install\n$ hcledit version\n```\n\n## Usage\n\n```\n$ hcledit --help\nA command line editor for HCL\n\nUsage:\n  hcledit [command]\n\nAvailable Commands:\n  attribute   Edit attribute\n  block       Edit block\n  body        Edit body\n  fmt         Format file\n  help        Help about any command\n  version     Print version\n\nFlags:\n  -f, --file string   A path of input file (default \"-\")\n  -h, --help          help for hcledit\n  -u, --update        Update files in-place\n\nUse \"hcledit [command] --help\" for more information about a command.\n```\n\n### attribute\n\n```\n$ hcledit attribute --help\nEdit attribute\n\nUsage:\n  hcledit attribute [flags]\n  hcledit attribute [command]\n\nAvailable Commands:\n  append      Append attribute\n  get         Get attribute\n  mv          Move attribute (Rename attribute key)\n  replace     Replace both the name and value of attribute\n  rm          Remove attribute\n  set         Set attribute\n\nFlags:\n  -h, --help   help for attribute\n\nGlobal Flags:\n  -f, --file string   A path of input file (default \"-\")\n  -u, --update        Update files in-place\n\nUse \"hcledit attribute [command] --help\" for more information about a command.\n```\n\nGiven the following file:\n\n```attr.hcl\nresource \"foo\" \"bar\" {\n  attr1 = \"val1\"\n  nested {\n    attr2 = \"val2\"\n  }\n}\n```\n\n```\n$ cat tmp/attr.hcl | hcledit attribute get resource.foo.bar.nested.attr2\n\"val2\"\n```\n\n```\n$ cat tmp/attr.hcl | hcledit attribute set resource.foo.bar.nested.attr2 '\"val3\"'\nresource \"foo\" \"bar\" {\n  attr1 = \"val1\"\n  nested {\n    attr2 = \"val3\"\n  }\n}\n```\n\n```\n$ cat tmp/attr.hcl | hcledit attribute mv resource.foo.bar.nested.attr2 resource.foo.bar.nested.attr3\nresource \"foo\" \"bar\" {\n  attr1 = \"val1\"\n  nested {\n    attr3 = \"val2\"\n  }\n}\n```\n\n```\n$ cat tmp/attr.hcl | hcledit attribute replace resource.foo.bar.nested.attr2 attr3 '\"val3\"'\nresource \"foo\" \"bar\" {\n  attr1 = \"val1\"\n  nested {\n    attr3 = \"val3\"\n  }\n}\n```\n\n```\n$ cat tmp/attr.hcl | hcledit attribute rm resource.foo.bar.attr1\nresource \"foo\" \"bar\" {\n  nested {\n    attr2 = \"val2\"\n  }\n}\n```\n\n```\n$ cat tmp/attr.hcl | hcledit attribute append resource.foo.bar.nested.attr3 '\"val3\"' --newline\nresource \"foo\" \"bar\" {\n  attr1 = \"val1\"\n  nested {\n    attr2 = \"val2\"\n\n    attr3 = \"val3\"\n  }\n}\n```\n\n### block\n\n```\n$ hcledit block --help\nEdit block\n\nUsage:\n  hcledit block [flags]\n  hcledit block [command]\n\nAvailable Commands:\n  append      Append block\n  get         Get block\n  list        List block\n  mv          Move block (Rename block type and labels)\n  new         Create a new block\n  rm          Remove block\n\nFlags:\n  -h, --help   help for block\n\nGlobal Flags:\n  -f, --file string   A path of input file (default \"-\")\n  -u, --update        Update files in-place\n\nUse \"hcledit block [command] --help\" for more information about a command.\n```\n\nGiven the following file:\n\n```block.hcl\nresource \"foo\" \"bar\" {\n  attr1 = \"val1\"\n}\n\nresource \"foo\" \"baz\" {\n  attr1 = \"val2\"\n}\n```\n\n```\n$ cat tmp/block.hcl | hcledit block list\nresource.foo.bar\nresource.foo.baz\n```\n\n```\n$ cat tmp/block.hcl | hcledit block get resource.foo.bar\nresource \"foo\" \"bar\" {\n  attr1 = \"val1\"\n}\n```\n\n```\n$ cat tmp/block.hcl | hcledit block mv resource.foo.bar resource.foo.qux\nresource \"foo\" \"qux\" {\n  attr1 = \"val1\"\n}\n\nresource \"foo\" \"baz\" {\n  attr1 = \"val2\"\n}\n```\n\n```\n$ cat tmp/block.hcl | hcledit block rm resource.foo.baz\nresource \"foo\" \"bar\" {\n  attr1 = \"val1\"\n}\n```\n\n```\n$ cat tmp/block.hcl | hcledit block append resource.foo.bar block1.label1 --newline\nresource \"foo\" \"bar\" {\n  attr1 = \"val1\"\n\n  block1 \"label1\" {\n  }\n}\n\nresource \"foo\" \"baz\" {\n  attr1 = \"val2\"\n}\n```\n\n```\n$ cat tmp/block.hcl | hcledit block new resource.foo.qux --newline\nresource \"foo\" \"bar\" {\n  attr1 = \"val1\"\n}\n\nresource \"foo\" \"baz\" {\n  attr1 = \"val2\"\n}\n\nresource \"foo\" \"qux\" {\n}\n```\n\n### body\n\n```\n$ hcledit body --help\nEdit body\n\nUsage:\n  hcledit body [flags]\n  hcledit body [command]\n\nAvailable Commands:\n  get         Get body\n\nFlags:\n  -h, --help   help for body\n\nGlobal Flags:\n  -f, --file string   A path of input file (default \"-\")\n  -u, --update        Update files in-place\n\nUse \"hcledit body [command] --help\" for more information about a command.\n```\n\nGiven the following file:\n\n```body.hcl\nresource \"foo\" \"bar\" {\n  attr1 = \"val1\"\n  nested {\n    attr2 = \"val2\"\n  }\n}\n```\n\n```\n$ cat tmp/body.hcl | hcledit body get resource.foo.bar\nattr1 = \"val1\"\nnested {\n  attr2 = \"val2\"\n}\n```\n\n### fmt\n\n```\n$ hcledit fmt --help\nFormat a file to a caconical style\n\nUsage:\n  hcledit fmt [flags]\n\nFlags:\n  -h, --help   help for fmt\n\nGlobal Flags:\n  -f, --file string   A path of input file (default \"-\")\n  -u, --update        Update files in-place\n```\n\nGiven the following file:\n\n```\n$ cat tmp/fmt.hcl\nresource \"foo\" \"bar\" {\n  attr1 = \"val1\"\n  attr2=\"val2\"\n}\n```\n\n```\n$ cat tmp/fmt.hcl | hcledit fmt\nresource \"foo\" \"bar\" {\n  attr1 = \"val1\"\n  attr2 = \"val2\"\n}\n```\n\n### Address escaping\n\nAddress escaping is supported for labels that contain `.`.\n\nGiven the following file:\n\n```body.hcl\nresource \"foo.bar\" {\n  attr1 = \"val1\"\n  nested {\n    attr2 = \"val2\"\n  }\n}\n```\n\n```\n$ cat tmp/attr.hcl | hcledit attribute get 'resource.foo\\.bar.nested.attr2'\n\"val2\"\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fminamijoyo%2Fhcledit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fminamijoyo%2Fhcledit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fminamijoyo%2Fhcledit/lists"}