{"id":22933474,"url":"https://github.com/bluebrown/go-template-cli","last_synced_at":"2025-12-15T22:09:36.418Z","repository":{"id":41960887,"uuid":"358058613","full_name":"bluebrown/go-template-cli","owner":"bluebrown","description":"render json, yaml \u0026 toml with go templates, from the command line","archived":false,"fork":false,"pushed_at":"2024-04-13T16:01:56.000Z","size":80,"stargazers_count":28,"open_issues_count":2,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-04-14T05:45:31.369Z","etag":null,"topics":["cli","go","go-template","golang","json","template","toml","yaml"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"0bsd","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bluebrown.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2021-04-14T22:30:26.000Z","updated_at":"2024-05-03T23:29:06.811Z","dependencies_parsed_at":"2024-04-13T16:48:59.962Z","dependency_job_id":"10e7d00b-4314-4326-a129-745d08f3400a","html_url":"https://github.com/bluebrown/go-template-cli","commit_stats":null,"previous_names":["bluebrown/jpipe","bluebrown/tpl"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/bluebrown/go-template-cli","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bluebrown%2Fgo-template-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bluebrown%2Fgo-template-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bluebrown%2Fgo-template-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bluebrown%2Fgo-template-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bluebrown","download_url":"https://codeload.github.com/bluebrown/go-template-cli/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bluebrown%2Fgo-template-cli/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270097287,"owners_count":24526641,"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","status":"online","status_checked_at":"2025-08-12T02:00:09.011Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","go-template","golang","json","template","toml","yaml"],"created_at":"2024-12-14T11:29:53.048Z","updated_at":"2025-12-15T22:09:31.347Z","avatar_url":"https://github.com/bluebrown.png","language":"Go","readme":"# Go Template CLI (tpl)\n\nRender json, yaml, \u0026 toml with go templates from the command line.\n\nThe templates are executed with the\n[text/template](https://pkg.go.dev/text/template) package. This means\nthey come with the additional risks and benefits of the text template\nengine.\n\n## Synopsis\n\n```console\nUsage: tpl [options] [templates]\n  -f, --file stringArray     template file path. Can be specified multiple times\n  -g, --glob stringArray     template file glob. Can be specified multiple times\n  -n, --name string          if specified, execute the template with the given name\n  -d, --decoder func         decoder to use for input data. Supported values: json, yaml, toml (default \"json\")\n      --option stringArray   option to pass to the template engine. Can be specified multiple times\n      --no-newline           do not print newline at the end of the output\n      --version              show version information and exit\n```\n\n## Input Data\n\nThe input data is read from stdin via pipe or redirection. It is\nactually not required to provide any input data. If no input data is\nprovided, the template is executed with nil data.\n\n```bash\n# Redirection\ntpl '{{ . }}' \u003c path/to/input.json\n# Pipe\ncurl localhost | tpl '{{ . }}'\n# nil data\ntpl '{{ . }}'\n```\n\n## Templates\n\nThe default templates name is `_gotpl_default` and positional arguments\nare parsed into this root template. That means while its possible to\nspecify multiple arguments, they will overwrite each other unless they\nuse the `define` keyword to define a named template that can be\nreferenced later when executing the template. If a named template is\nparsed multiple times, the last one will override the previous ones.\n\nTemplates from the flags `--file` and `--glob` are parsed in the order\nthey are specified. So the override rules of the text/template package\napply. If a file with the same name is specified multiple times, the\nlast one wins. Even if they are in different directories.\n\nThe behavior of the cli tries to stay consistent with the actual\nbehavior of the go template engine.\n\nIf the default template exists it will be used unless the `--name` flag\nis specified. If no default template exists because no positional\nargument has been provided, the template with the given file name is\nused, as long as only one file has been parsed. If multiple files have\nbeen parsed, the `--name` flag is required to avoid ambiguity.\n\n```bash\ntpl '{{ . }}' --file foo.tpl --glob 'templates/*.tpl'         # default will be used\ntpl --file foo.tpl                                            # foo.tpl will be used\ntpl --file foo.tpl --glob 'templates/*.tpl' --name foo.tpl    # the --name flag is required to select a template by name\n```\n\nThe ability to parse multiple templates makes sense when defining helper\nsnippets and other named templates to reference using the builtin\n`template` keyword or the custom `include` function which can be used in\npipelines.\n\nnote globs need to quotes to avoid shell expansion.\n\n## Decoders\n\nBy default input data is decoded as json and passed to the template to\nexecute. It is possible to use an alternative decoder. The supported\ndecoders are:\n\n- json\n- yaml\n- toml\n\nWhile json could technically be decoded using the yaml decoder, this is\nnot done by default for performance reasons.\n\n## Options\n\nThe `--options` flag is passed to the template engine. Possible options\ncan be found in the [documentation of the template\nengine](https://pkg.go.dev/text/template#Template.Option).\nThe only option currently known is `missingkey`. Since the input data is\ndecoded into `interface{}`, setting `missingkey=zero` will show `\u003cno\nvalue\u003e`, if the key does not exist, which is the same as the default.\nHowever, `missingkey=error` has some actual use cases.\n\n## Functions\n\nNext to the builtin functions, [Sprig\nfunctions](http://masterminds.github.io/sprig/) and some [custom\nfunction](./textfunc/) are available.\n\n## Installation\n\n### Binary\n\nDownload the binary from the [release\npage](https://github.com/bluebrown/go-template-cli/releases). For\nexample\n\n```bash\ncurl -fsSL https://github.com/bluebrown/go-template-cli/releases/latest/download/tpl-linux-amd64 \u003etpl\nchmod 755 tpl\n```\n\n### Go\n\nIf you have go installed, you can use the `go install` command to\ninstall the binary.\n\n```bash\ngo install github.com/bluebrown/go-template-cli/cmd/tpl@latest\n```\n\n## Example\n\nReview the\n[examples](https://github.com/bluebrown/go-template-cli/tree/main/assets/examples)\ndirectory, for more examples.\n\n```bash\ncurl -s https://jsonplaceholder.typicode.com/users | tpl '\u003ctable\u003e\n  \u003ccaption\u003eMy Address Book\u003c/caption\u003e\n  \u003ctr\u003e\n    \u003cth\u003eName\u003c/th\u003e\n    \u003cth\u003eEmail\u003c/th\u003e\n    \u003cth\u003ePhone\u003c/th\u003e\n    \u003cth\u003eAddress\u003c/th\u003e\n  \u003c/tr\u003e\n  {{- range . }}\n  \u003ctr\u003e\n    \u003cth\u003e{{ .name }}\u003c/th\u003e\n    \u003ctd\u003e{{ .email }}\u003c/td\u003e\n    \u003ctd\u003e{{ .phone }}\u003c/td\u003e\n    \u003ctd\u003e\n      \u003cul\u003e\n        {{- range $key, $val := .address }} {{ if ne $key \"geo\" }}\n        \u003cli\u003e\u003cstrong\u003e{{ $key }}:\u003c/strong\u003e \u0026nbsp; {{ $val }}\u003c/li\u003e\n        {{- end -}}\n        {{ end }}\n      \u003c/ul\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n  {{- end -}}\n\u003c/table\u003e'\n```\n\n\u003cdetails\u003e\n\u003csummary\u003eOutput\u003c/summary\u003e\n\n\u003ctable\u003e\n  \u003ccaption\u003eMy Address Book\u003c/caption\u003e\n  \u003ctr\u003e\n    \u003cth\u003eName\u003c/th\u003e\n    \u003cth\u003eEmail\u003c/th\u003e\n    \u003cth\u003ePhone\u003c/th\u003e\n    \u003cth\u003eAddress\u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003cth\u003eLeanne Graham\u003c/th\u003e\n    \u003ctd\u003eSincere@april.biz\u003c/td\u003e\n    \u003ctd\u003e1-770-736-8031 x56442\u003c/td\u003e\n    \u003ctd\u003e\n      \u003cul\u003e\n        \u003cli\u003e\u003cstrong\u003ecity:\u003c/strong\u003e \u0026nbsp; Gwenborough\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003estreet:\u003c/strong\u003e \u0026nbsp; Kulas Light\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003esuite:\u003c/strong\u003e \u0026nbsp; Apt. 556\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003ezipcode:\u003c/strong\u003e \u0026nbsp; 92998-3874\u003c/li\u003e\n      \u003c/ul\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003cth\u003eErvin Howell\u003c/th\u003e\n    \u003ctd\u003eShanna@melissa.tv\u003c/td\u003e\n    \u003ctd\u003e010-692-6593 x09125\u003c/td\u003e\n    \u003ctd\u003e\n      \u003cul\u003e\n        \u003cli\u003e\u003cstrong\u003ecity:\u003c/strong\u003e \u0026nbsp; Wisokyburgh\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003estreet:\u003c/strong\u003e \u0026nbsp; Victor Plains\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003esuite:\u003c/strong\u003e \u0026nbsp; Suite 879\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003ezipcode:\u003c/strong\u003e \u0026nbsp; 90566-7771\u003c/li\u003e\n      \u003c/ul\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003cth\u003eClementine Bauch\u003c/th\u003e\n    \u003ctd\u003eNathan@yesenia.net\u003c/td\u003e\n    \u003ctd\u003e1-463-123-4447\u003c/td\u003e\n    \u003ctd\u003e\n      \u003cul\u003e\n        \u003cli\u003e\u003cstrong\u003ecity:\u003c/strong\u003e \u0026nbsp; McKenziehaven\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003estreet:\u003c/strong\u003e \u0026nbsp; Douglas Extension\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003esuite:\u003c/strong\u003e \u0026nbsp; Suite 847\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003ezipcode:\u003c/strong\u003e \u0026nbsp; 59590-4157\u003c/li\u003e\n      \u003c/ul\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003cth\u003ePatricia Lebsack\u003c/th\u003e\n    \u003ctd\u003eJulianne.OConner@kory.org\u003c/td\u003e\n    \u003ctd\u003e493-170-9623 x156\u003c/td\u003e\n    \u003ctd\u003e\n      \u003cul\u003e\n        \u003cli\u003e\u003cstrong\u003ecity:\u003c/strong\u003e \u0026nbsp; South Elvis\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003estreet:\u003c/strong\u003e \u0026nbsp; Hoeger Mall\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003esuite:\u003c/strong\u003e \u0026nbsp; Apt. 692\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003ezipcode:\u003c/strong\u003e \u0026nbsp; 53919-4257\u003c/li\u003e\n      \u003c/ul\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003cth\u003eChelsey Dietrich\u003c/th\u003e\n    \u003ctd\u003eLucio_Hettinger@annie.ca\u003c/td\u003e\n    \u003ctd\u003e(254)954-1289\u003c/td\u003e\n    \u003ctd\u003e\n      \u003cul\u003e\n        \u003cli\u003e\u003cstrong\u003ecity:\u003c/strong\u003e \u0026nbsp; Roscoeview\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003estreet:\u003c/strong\u003e \u0026nbsp; Skiles Walks\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003esuite:\u003c/strong\u003e \u0026nbsp; Suite 351\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003ezipcode:\u003c/strong\u003e \u0026nbsp; 33263\u003c/li\u003e\n      \u003c/ul\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003cth\u003eMrs. Dennis Schulist\u003c/th\u003e\n    \u003ctd\u003eKarley_Dach@jasper.info\u003c/td\u003e\n    \u003ctd\u003e1-477-935-8478 x6430\u003c/td\u003e\n    \u003ctd\u003e\n      \u003cul\u003e\n        \u003cli\u003e\u003cstrong\u003ecity:\u003c/strong\u003e \u0026nbsp; South Christy\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003estreet:\u003c/strong\u003e \u0026nbsp; Norberto Crossing\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003esuite:\u003c/strong\u003e \u0026nbsp; Apt. 950\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003ezipcode:\u003c/strong\u003e \u0026nbsp; 23505-1337\u003c/li\u003e\n      \u003c/ul\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003cth\u003eKurtis Weissnat\u003c/th\u003e\n    \u003ctd\u003eTelly.Hoeger@billy.biz\u003c/td\u003e\n    \u003ctd\u003e210.067.6132\u003c/td\u003e\n    \u003ctd\u003e\n      \u003cul\u003e\n        \u003cli\u003e\u003cstrong\u003ecity:\u003c/strong\u003e \u0026nbsp; Howemouth\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003estreet:\u003c/strong\u003e \u0026nbsp; Rex Trail\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003esuite:\u003c/strong\u003e \u0026nbsp; Suite 280\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003ezipcode:\u003c/strong\u003e \u0026nbsp; 58804-1099\u003c/li\u003e\n      \u003c/ul\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003cth\u003eNicholas Runolfsdottir V\u003c/th\u003e\n    \u003ctd\u003eSherwood@rosamond.me\u003c/td\u003e\n    \u003ctd\u003e586.493.6943 x140\u003c/td\u003e\n    \u003ctd\u003e\n      \u003cul\u003e\n        \u003cli\u003e\u003cstrong\u003ecity:\u003c/strong\u003e \u0026nbsp; Aliyaview\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003estreet:\u003c/strong\u003e \u0026nbsp; Ellsworth Summit\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003esuite:\u003c/strong\u003e \u0026nbsp; Suite 729\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003ezipcode:\u003c/strong\u003e \u0026nbsp; 45169\u003c/li\u003e\n      \u003c/ul\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003cth\u003eGlenna Reichert\u003c/th\u003e\n    \u003ctd\u003eChaim_McDermott@dana.io\u003c/td\u003e\n    \u003ctd\u003e(775)976-6794 x41206\u003c/td\u003e\n    \u003ctd\u003e\n      \u003cul\u003e\n        \u003cli\u003e\u003cstrong\u003ecity:\u003c/strong\u003e \u0026nbsp; Bartholomebury\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003estreet:\u003c/strong\u003e \u0026nbsp; Dayna Park\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003esuite:\u003c/strong\u003e \u0026nbsp; Suite 449\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003ezipcode:\u003c/strong\u003e \u0026nbsp; 76495-3109\u003c/li\u003e\n      \u003c/ul\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003cth\u003eClementina DuBuque\u003c/th\u003e\n    \u003ctd\u003eRey.Padberg@karina.biz\u003c/td\u003e\n    \u003ctd\u003e024-648-3804\u003c/td\u003e\n    \u003ctd\u003e\n      \u003cul\u003e\n        \u003cli\u003e\u003cstrong\u003ecity:\u003c/strong\u003e \u0026nbsp; Lebsackbury\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003estreet:\u003c/strong\u003e \u0026nbsp; Kattie Turnpike\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003esuite:\u003c/strong\u003e \u0026nbsp; Suite 198\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003ezipcode:\u003c/strong\u003e \u0026nbsp; 31428-2261\u003c/li\u003e\n      \u003c/ul\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\u003c/table\u003e\n\n\u003c/details\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbluebrown%2Fgo-template-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbluebrown%2Fgo-template-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbluebrown%2Fgo-template-cli/lists"}