github.com/suntong/easygen@v5.3.0+incompatible/README.md (about) 1 # easygen 2 <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section --> 3 [![All Contributors](https://img.shields.io/badge/all_contributors-7-orange.svg?style=flat-square)](#contributors-) 4 <!-- ALL-CONTRIBUTORS-BADGE:END --> 5 6 [![MIT License](http://img.shields.io/badge/License-MIT-blue.svg)](LICENSE) 7 [![GoDoc](https://godoc.org/github.com/go-easygen/easygen?status.svg)](http://godoc.org/github.com/go-easygen/easygen) 8 [![Go Report Card](https://goreportcard.com/badge/github.com/go-easygen/easygen)](https://goreportcard.com/report/github.com/go-easygen/easygen) 9 [![Build Status](https://github.com/go-easygen/easygen/actions/workflows/go-release-build.yml/badge.svg?branch=master)](https://github.com/go-easygen/easygen/actions/workflows/go-release-build.yml) 10 [![PoweredBy WireFrame](https://github.com/go-easygen/wireframe/blob/master/PoweredBy-WireFrame-B.svg)](http://godoc.org/github.com/go-easygen/wireframe) 11 12 13 14 The easy to use universal code/text generator 15 16 > _`easygen` is to `json` what `xslt` is to `xml`, but much more powerful and versatile._ 17 18 > _`easygen` has been such a great help to us, making so many mundane tasks easier (and fun) to do._ 19 20 ## TOC 21 - [easygen - Easy to use universal code/text generator](#easygen---easy-to-use-universal-codetext-generator) 22 - [Usage](#usage) 23 - [$ easygen](#-easygen) 24 - [Details](#details) 25 - [Download/install binaries](#downloadinstall-binaries) 26 - [The binary executables](#the-binary-executables) 27 - [Distro package](#distro-package) 28 - [Debian package](#debian-package) 29 - [Install Source](#install-source) 30 - [Author](#author) 31 - [Contributors](#contributors-) 32 33 ## easygen - Easy to use universal code/text generator 34 35 Command `easygen` is an easy to use universal code/text generator. 36 37 It can be used as a text or html generator for _arbitrary_ purposes with _arbitrary_ data and templates. It is a good [GSL](https://github.com/imatix/gsl) replacement, as it 38 39 - is more easy to define driving data, in form of YML instead of XML 40 - has more powerful template engine that based on Go template. 41 You can also write your own function in Go to customize your template. 42 - there are lots of transformation support functions builtin inside it, check out the full list with sample usages and results [here](https://github.com/go-easygen/easygen/issues/25). 43 - apart from the above sample usages, it has extensive documentations like [this](https://github.com/go-easygen/easygen/wiki/Docs:-Easygen-usage). Check out the [wiki](https://github.com/go-easygen/easygen/wiki/) for the full list. 44 45 You can even use easygen as [a generic Go template testing tool](https://github.com/go-easygen/easygen/wiki/Tip:-Testing-the-templates-on-the-fly) using the `-ts` commandline option, and much more. 46 47 Note this document is for `easygen` versions 4.0+. For historic versions check out the [Different Versions](https://github.com/go-easygen/easygen/wiki/Docs:-Different-Versions) section. 48 49 50 ## Usage 51 52 ### $ easygen 53 ```sh 54 easygen version 5.3.0 55 56 Usage: 57 easygen [flags] template_name [data_filename [data_filename...]] 58 59 Flags: 60 61 -debug level 62 debugging level 63 -ej extension 64 extension of json file (default ".json") 65 -et extension 66 extension of template file (default ".tmpl") 67 -ey extension 68 extension of yaml file (default ".yaml") 69 -ts string 70 template string (in text) 71 72 template_name: The name for the template file. 73 - Can have the extension (specified by -et) or without it. 74 - Can include the path as well. 75 - Can be a comma-separated list giving many template files, in which case 76 at least one data_filename must be given. 77 78 data_filename(s): The name for the .yaml or .json data. 79 - If omitted derive from the template_name. 80 - Can have the extension or without it. If withot extension, 81 will try the .yaml file first then .json 82 - Can include the path as well. 83 - Can have more than one data files given on cli, separated by spaces, 84 in which case multiple outputs will be produced based on the inputs. 85 - Can be a comma-separated list giving many data files, in which case 86 data will be merged together as if provided from a single file. 87 - If there is a single data_filename, and it is "-", 88 then read the data (.yaml or .json format) from stdin. 89 90 Flag defaults can be overridden by corresponding environment variable, e.g.: 91 EASYGEN_EY=.yml EASYGEN_ET=.tpl easygen ... 92 ``` 93 94 ## Details 95 96 It can be used as a code generator, for example, command line parameter handling code generator, or anything that is structurally repetitive, like the following: 97 98 - [Introduction to easygen and its philosophy ](https://suntong.github.io/blogs/2016/01/01/easygen---easy-to-use-universal-code/text-generator) 99 - [What is the "XSLT" equivalent for JSON? Here is the new answer](https://dev.to/suntong/what-is-the-xslt-equivalent-for-json-here-is-the-new-answer-7la) 100 - [Transforming json data with easygen](https://dev.to/suntong/transforming-json-data-with-easygen-4g2i) 101 - [Easygen is now coding itself ](https://sfxpt.wordpress.com/2015/07/04/easygen-is-now-coding-itself/) 102 - [Showcasing the power of easygen with ffcvt ](https://sfxpt.wordpress.com/2015/08/02/showcasing-the-power-of-easygen-with-ffcvt/) 103 - [Easygen for HTML mock-up ](https://sfxpt.wordpress.com/2015/07/10/easygen-for-mock-up/) 104 - [Moving beyond code-gen and mock-up, using easygen in real life creating GPT partitions](https://suntong.github.io/blogs/2015/12/26/creating-gpt-partitions-easily-on-the-command-line) 105 106 Ready to get started? Then check out [Getting Started](https://github.com/go-easygen/easygen/wiki/Getting-Started) to start building your way to turn your data into any form, any way you want. 107 108 ## Install Debian/Ubuntu package 109 110 sudo apt install -y easygen 111 112 ## Download/install binaries 113 114 - The latest binary executables are available 115 as the result of the Continuous-Integration (CI) process. 116 - I.e., they are built automatically right from the source code at every git release by [GitHub Actions](https://docs.github.com/en/actions). 117 - There are two ways to get/install such binary executables 118 * Using the **binary executables** directly, or 119 * Using **packages** for your distro 120 121 ### The binary executables 122 123 - The latest binary executables are directly available under 124 https://github.com/go-easygen/easygen/releases/latest 125 - Pick & choose the one that suits your OS and its architecture. E.g., for Linux, it would be the `easygen_verxx_linux_amd64.tar.gz` file. 126 - Available OS for binary executables are 127 * Linux 128 * Mac OS (darwin) 129 * Windows 130 - If your OS and its architecture is not available in the download list, please let me know and I'll add it. 131 - The manual installation is just to unpack it and move/copy the binary executable to somewhere in `PATH`. For example, 132 133 ``` sh 134 tar -xvf easygen_*_linux_amd64.tar.gz 135 sudo mv -v easygen_*_linux_amd64/easygen /usr/local/bin/ 136 rmdir -v easygen_*_linux_amd64 137 ``` 138 139 140 ### Distro package 141 142 - [Packages available for Linux distros](https://cloudsmith.io/~suntong/repos/repo/packages/) are 143 * [Alpine Linux](https://cloudsmith.io/~suntong/repos/repo/setup/#formats-alpine) 144 * [Debian](https://cloudsmith.io/~suntong/repos/repo/setup/#formats-deb) 145 * [RedHat](https://cloudsmith.io/~suntong/repos/repo/setup/#formats-rpm) 146 147 The repo setup instruction url has been given above. 148 For example, for [Debian](https://cloudsmith.io/~suntong/repos/repo/setup/#formats-deb) -- 149 150 ### Debian package 151 152 153 ```sh 154 curl -1sLf \ 155 'https://dl.cloudsmith.io/public/suntong/repo/setup.deb.sh' \ 156 | sudo -E bash 157 158 # That's it. You then can do your normal operations, like 159 160 sudo apt update 161 apt-cache policy easygen 162 163 sudo apt install -y easygen 164 ``` 165 166 ## Install Source 167 168 To install the source code instead: 169 170 ``` 171 go install github.com/go-easygen/easygen@latest 172 ``` 173 174 ## Author 175 176 Tong SUN 177 ![suntong from cpan.org](https://img.shields.io/badge/suntong-%40cpan.org-lightgrey.svg "suntong from cpan.org") 178 179 _Powered by_ [**WireFrame**](https://github.com/go-easygen/wireframe) 180 [![PoweredBy WireFrame](https://github.com/go-easygen/wireframe/blob/master/PoweredBy-WireFrame-Y.svg)](http://godoc.org/github.com/go-easygen/wireframe) 181 the _one-stop wire-framing solution_ for Go cli based projects, from _init_ to _deploy_. 182 183 ## Contributors ✨ 184 185 Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)): 186 187 <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --> 188 <!-- prettier-ignore-start --> 189 <!-- markdownlint-disable --> 190 <table> 191 <tr> 192 <td align="center"><a href="https://github.com/suntong"><img src="https://avatars.githubusercontent.com/u/422244?v=4?s=100" width="100px;" alt=""/><br /><sub><b>suntong</b></sub></a><br /><a href="https://github.com/go-easygen/easygen/commits?author=suntong" title="Code">💻</a> <a href="#ideas-suntong" title="Ideas, Planning, & Feedback">🤔</a> <a href="#design-suntong" title="Design">🎨</a> <a href="#data-suntong" title="Data">🔣</a> <a href="https://github.com/go-easygen/easygen/commits?author=suntong" title="Tests">⚠️</a> <a href="https://github.com/go-easygen/easygen/issues?q=author%3Asuntong" title="Bug reports">🐛</a> <a href="https://github.com/go-easygen/easygen/commits?author=suntong" title="Documentation">📖</a> <a href="#blog-suntong" title="Blogposts">📝</a> <a href="#example-suntong" title="Examples">💡</a> <a href="#tutorial-suntong" title="Tutorials">✅</a> <a href="#tool-suntong" title="Tools">🔧</a> <a href="#platform-suntong" title="Packaging/porting to new platform">📦</a> <a href="https://github.com/go-easygen/easygen/pulls?q=is%3Apr+reviewed-by%3Asuntong" title="Reviewed Pull Requests">👀</a> <a href="#question-suntong" title="Answering Questions">💬</a> <a href="#maintenance-suntong" title="Maintenance">🚧</a> <a href="#infra-suntong" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td> 193 <td align="center"><a href="http://gerrit.sdf.org/"><img src="https://avatars.githubusercontent.com/u/5132989?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Gerrit Renker</b></sub></a><br /><a href="https://github.com/go-easygen/easygen/commits?author=grrtrr" title="Code">💻</a> <a href="#ideas-grrtrr" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/go-easygen/easygen/issues?q=author%3Agrrtrr" title="Bug reports">🐛</a> <a href="#userTesting-grrtrr" title="User Testing">📓</a> <a href="#talk-grrtrr" title="Talks">📢</a> <a href="#content-grrtrr" title="Content">🖋</a> <a href="#blog-grrtrr" title="Blogposts">📝</a></td> 194 <td align="center"><a href="https://github.com/bruston"><img src="https://avatars.githubusercontent.com/u/3519911?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Benjamin Ruston</b></sub></a><br /><a href="https://github.com/go-easygen/easygen/commits?author=bruston" title="Code">💻</a> <a href="https://github.com/go-easygen/easygen/issues?q=author%3Abruston" title="Bug reports">🐛</a> <a href="#userTesting-bruston" title="User Testing">📓</a></td> 195 <td align="center"><a href="https://github.com/sanjaymsh"><img src="https://avatars.githubusercontent.com/u/66668807?v=4?s=100" width="100px;" alt=""/><br /><sub><b>sanjaymsh</b></sub></a><br /><a href="#platform-sanjaymsh" title="Packaging/porting to new platform">📦</a></td> 196 <td align="center"><a href="https://wiki.debian.org/AnthonyFok"><img src="https://avatars.githubusercontent.com/u/1274764?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Anthony Fok</b></sub></a><br /><a href="https://github.com/go-easygen/easygen/issues?q=author%3Aanthonyfok" title="Bug reports">🐛</a> <a href="https://github.com/go-easygen/easygen/pulls?q=is%3Apr+reviewed-by%3Aanthonyfok" title="Reviewed Pull Requests">👀</a> <a href="#maintenance-anthonyfok" title="Maintenance">🚧</a> <a href="#userTesting-anthonyfok" title="User Testing">📓</a></td> 197 <td align="center"><a href="https://github.com/ghost"><img src="https://avatars.githubusercontent.com/u/10137?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Deleted user</b></sub></a><br /><a href="https://github.com/go-easygen/easygen/issues?q=author%3Aghost" title="Bug reports">🐛</a> <a href="#ideas-ghost" title="Ideas, Planning, & Feedback">🤔</a> <a href="#userTesting-ghost" title="User Testing">📓</a></td> 198 <td align="center"><a href="https://github.com/romz-pl"><img src="https://avatars.githubusercontent.com/u/32552206?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Zbigniew Romanowski</b></sub></a><br /><a href="https://github.com/go-easygen/easygen/issues?q=author%3Aromz-pl" title="Bug reports">🐛</a> <a href="#ideas-romz-pl" title="Ideas, Planning, & Feedback">🤔</a> <a href="#userTesting-romz-pl" title="User Testing">📓</a></td> 199 </tr> 200 </table> 201 202 <!-- markdownlint-restore --> 203 <!-- prettier-ignore-end --> 204 205 <!-- ALL-CONTRIBUTORS-LIST:END --> 206 207 This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!