retab

module
v0.66.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2024 License: Apache-2.0

README

retab ➡️

Simplify your config management with retab. This tool transforms .retab files (using hcl syntax)into YAML or JSON, allowing you to write in HCL and enjoy the readability benefits of tab indentation.

⭐️ Key Features

  1. Compile: Transform .retab/*.retab files into .yaml or .json files.
  2. Format: Format .retab/*.retab files for clearer and accessable indentation.

🛠️ Install from the Source

go install github.com/walteh/retab/cmd/retab

🚀 Quick Start

  1. Create a .retab/*.retab file:
BRANCH = "main"

gen "hello-world-github-workflow" {
	path   = "./.github/workflows/hello-world.yaml"
	schema = "https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/github-workflow.json"
	data = {
		name = "hello-world"

		on = {
			push = {
				branches = [BRANCH]
			}
		}

		jobs = {
			say-hello = my_custom_type.my_custom_name.another_custom_type.do_whatever_you_want
		}
	}
}

my_custom_type "my_custom_name" {
	another_custom_type {
		do_whatever_you_want = {
			runs-on = "ubuntu-latest"
			steps = [
				{
					name = "Checkout"
					uses = "actions/checkout@v4"
					with = {
						fetch-depth = 1
					}
				},
				{
					name = "Run tests"
					run  = <<SHELL
							echo "Hello world"
						SHELL
				}
			]
		}
	}
}
  1. Format with retab fmt:
retab fmt
  1. Compile with retab gen:
retab gen

This generates a .yaml or .json file based on your .retab/*.retab file.

# code generated by retab. DO NOT EDIT.
# join the fight against yaml @ github.com/walteh/retab

# source: ".retab/hello-world.retab"

name: hello-world
"on":
    push:
        branches:
            - main
jobs:
    say-hello:
        runs-on: ubuntu-latest
        steps:
            - name: Checkout
              uses: actions/checkout@v4
              with:
                fetch-depth: 1
            - name: Run tests
              run: |
                echo "Hello world"

🤨 Why retab?

retab offers a streamlined approach to managing configurations. It combines the simplicity of HCL with the power of YAML/JSON, all while making indentation more readable and organized with tabs.

🤯 Additional Formatting Capabilities

For advanced users, retab extends its formatting prowess beyond .retab files:

Format .hcl Files
retab wfmt --file=./main.hcl
Format .proto Files
retab wfmt --file=./main.proto
Format .tf Files

Requires terraform fmt

retab wfmt --file=./main.tf
Format .dart Files

Requires dart format

retab wfmt --file=./main.dart

🥊 Join the fight against YAML!

retab is an open source project, and we welcome your contributions. To get started, just submit a pull request.

🛜 Keywords

  • YAML and JSON Compiler
  • HCL Formatting
  • Config Management Tool
  • Terraform Formatting
  • Dart File Formatting
  • Terraform Formatter
  • HCL Formatter
  • HCL to YAML
  • HCL to JSON
  • HCL to YAML Compiler
  • HCL to JSON Compiler
  • HashiCorp Configuration Language
  • YAML Configuration
  • JSON Configuration
  • Tab Indentation in Terraform

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL