go-scaffold

command module
v0.0.0-...-744e601 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: MIT Imports: 2 Imported by: 0

README

go-scaffold

go-scaffold is a cookiecutter-like CLI & library to generate templated artifacts

Installation

$ task install

Usage

Creating a template

You can see same-repository for an example template

$ tree sample-template

├── schema.yaml
└── template
    └── {{ project_name }}
        └── {{ project_name }}.txt

3 directories, 2 files

At the root of the template we expect two things

  • schema.yaml
  • template
schema.yaml
$ cat sample-template\schema.yaml

name: Test Template
type: object
schema:
  project_name:
    type: string
required:
  - project_name

schema.yaml uses (json-schema)[https://json-schema.org/] to validate the variables that will be interpolated in the template files

template

template is a directory containing files that will be parsed with (pongo2)[https://github.com/flosch/pongo2].

NOTE: Both the contents and the filenames of files will be rendered with the variables provided

Create template input

Create a YAML file to store the variables we want to have replaced in our generated artifact

$ cat input.yaml

project_name: My Project
Generating the template
$ go-scaffold /path/to/sample-template --input-file /path/to/input.yaml --output-directory /output/path

$ tree /output/path

path
└── My Project
    └── My Project.txt

2 directories, 1 file

$ cat /output/path/My\ Project/My\ Project.txt

My Project

LICENSE

(MIT)[https://github.com/cybercyst/go-scaffold/blob/main/LICENSE]

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
internal
pkg

Jump to

Keyboard shortcuts

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