tmplwizard

command module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2018 License: MIT Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

banner

GitHub release MIT License Go Report Card PRs Welcome

Generates an interactive wizard from prompts in a text/template template file

tmplwizard generates a cli wizard based on prompt functions in a template to allow the user to dynamically provide values.

Prompt Functions:
PromptString prompts the user for a string value which can be stored in a variable for later use in the template.
PromptBool allows for conditional rendering of template sections.

Install

Option 1: Binary

Download the latest release from https://github.com/jakewarren/tmplwizard/releases

Option 2: From source

go get github.com/jakewarren/tmplwizard

Usage

Run the included example: go run main.go examples/nested_conditionals.tmpl

examples/nested_conditionals.tmpl:

{{$stringVariable := .PromptString "Enter any string: " -}}
The string you entered ({{$stringVariable}}) is now stored in a variable.

{{ if .PromptBool "Do you want to expand the first section ---> " -}}
This text appears if you confirm the first conditional.

{{ if .PromptBool "Do you want to expand the nested conditional ---> " -}}
This text only appears if you answered yes to both of the previous questions.
{{end -}}
{{end -}}

Background

I created this project as a way to quickly scaffold out text files such as READMEs. There are probably other uses that I'm not thinking of.

Changes

All notable changes to this project will be documented in the changelog.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

License

MIT © 2017 Jake Warren

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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