├── .gitignore
├── test
├── issues
│ ├── 13
│ │ ├── examples.sh
│ │ ├── expect.txt
│ │ ├── 13.txt.tmpl
│ │ └── .13.yaml
│ ├── 9a
│ │ ├── expect.txt
│ │ ├── 9a.txt.tmpl
│ │ └── examples.sh
│ ├── 9b
│ │ ├── 9b.txt.tmpl
│ │ ├── examples.sh
│ │ └── expect.txt
│ ├── 9c
│ │ ├── 9c.txt.tmpl
│ │ ├── examples.sh
│ │ └── expect.txt
│ ├── 9d
│ │ ├── 9d.txt.tmpl
│ │ ├── examples.sh
│ │ └── expect.txt
│ ├── 9e
│ │ ├── 9e.txt.tmpl
│ │ ├── examples.sh
│ │ └── expect.txt
│ └── 9f
│ │ ├── examples.sh
│ │ ├── 9f.txt.tmpl
│ │ └── expect.txt
├── Makefile
└── test
├── vendor
├── github.com
│ ├── gomatic
│ │ ├── funcmap
│ │ │ ├── .gitignore
│ │ │ ├── go.mod
│ │ │ ├── .travis.yml
│ │ │ ├── README.md
│ │ │ └── go.sum
│ │ └── clock
│ │ │ ├── .gitignore
│ │ │ ├── README.md
│ │ │ ├── .travis.yml
│ │ │ ├── go.mod
│ │ │ ├── clock.go
│ │ │ └── go.sum
│ ├── kardianos
│ │ └── osext
│ │ │ ├── go.mod
│ │ │ ├── osext_go18.go
│ │ │ ├── osext_plan9.go
│ │ │ ├── README.md
│ │ │ ├── osext_windows.go
│ │ │ ├── osext.go
│ │ │ ├── osext_procfs.go
│ │ │ ├── LICENSE
│ │ │ └── osext_sysctl.go
│ ├── urfave
│ │ └── cli
│ │ │ └── v2
│ │ │ ├── .flake8
│ │ │ ├── .gitignore
│ │ │ ├── go.mod
│ │ │ ├── sort.go
│ │ │ ├── cli.go
│ │ │ ├── LICENSE
│ │ │ ├── args.go
│ │ │ ├── go.sum
│ │ │ ├── funcs.go
│ │ │ ├── category.go
│ │ │ ├── README.md
│ │ │ ├── flag_path.go
│ │ │ ├── flag_string.go
│ │ │ ├── flag_bool.go
│ │ │ ├── flag_int.go
│ │ │ ├── parse.go
│ │ │ ├── flag_uint.go
│ │ │ ├── flag_int64.go
│ │ │ ├── flag_uint64.go
│ │ │ ├── flag_float64.go
│ │ │ ├── flag_generic.go
│ │ │ ├── flag_duration.go
│ │ │ ├── CODE_OF_CONDUCT.md
│ │ │ ├── docs.go
│ │ │ ├── errors.go
│ │ │ ├── flag_timestamp.go
│ │ │ ├── template.go
│ │ │ ├── flag_int64_slice.go
│ │ │ ├── flag_float64_slice.go
│ │ │ ├── flag_int_slice.go
│ │ │ ├── fish.go
│ │ │ ├── flag_string_slice.go
│ │ │ └── context.go
│ ├── russross
│ │ └── blackfriday
│ │ │ └── v2
│ │ │ ├── go.mod
│ │ │ ├── .gitignore
│ │ │ ├── .travis.yml
│ │ │ ├── esc.go
│ │ │ ├── doc.go
│ │ │ └── LICENSE.txt
│ ├── shurcooL
│ │ └── sanitized_anchor_name
│ │ │ ├── go.mod
│ │ │ ├── .travis.yml
│ │ │ ├── main.go
│ │ │ ├── README.md
│ │ │ └── LICENSE
│ ├── imdario
│ │ └── mergo
│ │ │ ├── go.mod
│ │ │ ├── .deepsource.toml
│ │ │ ├── .travis.yml
│ │ │ ├── go.sum
│ │ │ ├── .gitignore
│ │ │ ├── LICENSE
│ │ │ ├── mergo.go
│ │ │ ├── CODE_OF_CONDUCT.md
│ │ │ ├── doc.go
│ │ │ └── map.go
│ └── cpuguy83
│ │ └── go-md2man
│ │ └── v2
│ │ ├── md2man
│ │ └── md2man.go
│ │ └── LICENSE.md
├── gopkg.in
│ └── yaml.v2
│ │ ├── go.mod
│ │ ├── .travis.yml
│ │ ├── NOTICE
│ │ ├── writerc.go
│ │ ├── LICENSE.libyaml
│ │ ├── sorter.go
│ │ ├── README.md
│ │ ├── yamlprivateh.go
│ │ └── resolve.go
└── modules.txt
├── examples
├── basic
│ ├── .basic.yaml
│ ├── basic.txt.tmpl
│ ├── expect.txt
│ └── examples.sh
├── document
│ ├── .document.yaml
│ ├── document.html.tmpl
│ ├── examples.sh
│ └── expect.txt
├── functions
│ ├── examples.sh
│ ├── functions.txt.tmpl
│ └── expect.txt
├── pod
│ ├── examples.sh
│ ├── .pod.yaml
│ └── pod.yaml.tmpl
├── README.md
├── environment
│ ├── environment.txt.tmpl
│ ├── examples.sh
│ └── expect.txt
└── Makefile
├── .env.mk
├── TODO.md
├── cmd
└── renderizer
│ └── main_test.go
├── .travis.yml
├── go.mod
├── scripts
├── test-iterate
└── test-expect
├── .goreleaser-darwin.yml
├── .version.mk
├── .circleci
└── config.yml
├── .github
└── workflows
│ └── release.yml
├── Makefile
├── README.md
├── .goreleaser.yml
├── pkg
└── renderizer
│ └── renderizer_test.go
└── go.sum
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea/
2 | build/
3 | release/
4 |
--------------------------------------------------------------------------------
/test/issues/9a/expect.txt:
--------------------------------------------------------------------------------
1 | foobar == foobar
2 |
3 |
--------------------------------------------------------------------------------
/vendor/github.com/gomatic/funcmap/.gitignore:
--------------------------------------------------------------------------------
1 | .idea/
2 |
--------------------------------------------------------------------------------
/test/Makefile:
--------------------------------------------------------------------------------
1 | .PHONY : test
2 |
3 | test:
4 | @bash test
5 |
--------------------------------------------------------------------------------
/test/issues/13/examples.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | renderizer
4 |
--------------------------------------------------------------------------------
/test/issues/9a/9a.txt.tmpl:
--------------------------------------------------------------------------------
1 | {{.Technical_user.Nginx}} == foobar
2 |
--------------------------------------------------------------------------------
/vendor/github.com/kardianos/osext/go.mod:
--------------------------------------------------------------------------------
1 | module github.com/kardianos/osext
2 |
--------------------------------------------------------------------------------
/vendor/github.com/urfave/cli/v2/.flake8:
--------------------------------------------------------------------------------
1 | [flake8]
2 | max-line-length = 120
3 |
--------------------------------------------------------------------------------
/test/issues/9b/9b.txt.tmpl:
--------------------------------------------------------------------------------
1 | {{.A}} == map[B:[1 2 3]]
2 | {{.A.B}} == [1 2 3]
3 |
--------------------------------------------------------------------------------
/test/issues/9c/9c.txt.tmpl:
--------------------------------------------------------------------------------
1 | {{.A}} == map[B:[A B C]]
2 | {{.A.B}} == [A B C]
3 |
--------------------------------------------------------------------------------
/test/issues/9d/9d.txt.tmpl:
--------------------------------------------------------------------------------
1 | {{.A}} == map[B:[1 A 3]]
2 | {{.A.B}} == [1 A 3]
3 |
--------------------------------------------------------------------------------
/test/issues/9e/9e.txt.tmpl:
--------------------------------------------------------------------------------
1 | {{.A}} == map[B:[A 2 3]]
2 | {{.A.B}} == [A 2 3]
3 |
--------------------------------------------------------------------------------
/test/issues/9b/examples.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | renderizer --a.b=1 --a.b=2 --a.b=3
4 |
--------------------------------------------------------------------------------
/test/issues/9c/examples.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | renderizer --a.b=A --a.b=B --a.b=C
4 |
--------------------------------------------------------------------------------
/test/issues/9d/examples.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | renderizer --a.b=1 --a.b=A --a.b=3
4 |
--------------------------------------------------------------------------------
/test/issues/9e/examples.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | renderizer --a.b=A --a.b=2 --a.b=3
4 |
--------------------------------------------------------------------------------
/examples/basic/.basic.yaml:
--------------------------------------------------------------------------------
1 | Name: Renderizer
2 | Items:
3 | - one
4 | - two
5 | - three
6 |
--------------------------------------------------------------------------------
/test/issues/9a/examples.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | renderizer --technical_user.nginx=foobar
4 |
--------------------------------------------------------------------------------
/test/issues/9b/expect.txt:
--------------------------------------------------------------------------------
1 | map[B:[1 2 3]] == map[B:[1 2 3]]
2 | [1 2 3] == [1 2 3]
3 |
4 |
--------------------------------------------------------------------------------
/test/issues/9c/expect.txt:
--------------------------------------------------------------------------------
1 | map[B:[A B C]] == map[B:[A B C]]
2 | [A B C] == [A B C]
3 |
4 |
--------------------------------------------------------------------------------
/test/issues/9d/expect.txt:
--------------------------------------------------------------------------------
1 | map[B:[1 A 3]] == map[B:[1 A 3]]
2 | [1 A 3] == [1 A 3]
3 |
4 |
--------------------------------------------------------------------------------
/test/issues/9e/expect.txt:
--------------------------------------------------------------------------------
1 | map[B:[A 2 3]] == map[B:[A 2 3]]
2 | [A 2 3] == [A 2 3]
3 |
4 |
--------------------------------------------------------------------------------
/examples/document/.document.yaml:
--------------------------------------------------------------------------------
1 | items:
2 | - apple
3 | - banana
4 | - cherry
5 | foo: true
6 |
--------------------------------------------------------------------------------
/vendor/github.com/russross/blackfriday/v2/go.mod:
--------------------------------------------------------------------------------
1 | module github.com/russross/blackfriday/v2
2 |
--------------------------------------------------------------------------------
/test/issues/13/expect.txt:
--------------------------------------------------------------------------------
1 |
2 | echo "16.04 aka ubu1604"
3 |
4 | echo "18.04 aka ubu1804"
5 |
6 |
7 |
--------------------------------------------------------------------------------
/test/issues/13/13.txt.tmpl:
--------------------------------------------------------------------------------
1 | {{ range .OSLIST }}
2 | echo "{{ .UBUNTU }} aka {{ .OSID }}"
3 | {{ end }}
4 |
--------------------------------------------------------------------------------
/test/issues/9f/examples.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | renderizer --a.b.c='kills(a,b)' --a.b=A --a.b=B --a.b=C
4 |
--------------------------------------------------------------------------------
/vendor/github.com/shurcooL/sanitized_anchor_name/go.mod:
--------------------------------------------------------------------------------
1 | module github.com/shurcooL/sanitized_anchor_name
2 |
--------------------------------------------------------------------------------
/examples/basic/basic.txt.tmpl:
--------------------------------------------------------------------------------
1 | Hello: {{ .Name }}!
2 | {{ range $i, $c := .Items }}- {{ $i }}: {{ $c }}
3 | {{ end }}
4 |
--------------------------------------------------------------------------------
/test/issues/13/.13.yaml:
--------------------------------------------------------------------------------
1 | OSLIST:
2 | - UBUNTU: '16.04'
3 | OSID: 'ubu1604'
4 | - UBUNTU: '18.04'
5 | OSID: 'ubu1804'
6 |
--------------------------------------------------------------------------------
/test/issues/9f/9f.txt.tmpl:
--------------------------------------------------------------------------------
1 | {{.A}} == map[B:map[C:kills(a,b)]]
2 | {{.A.B}} == map[C:kills(a,b)]
3 | {{.A.B.C}} == kills(a,b)
4 |
--------------------------------------------------------------------------------
/examples/functions/examples.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | name=$(basename ${PWD})
3 | renderizer
4 | renderizer ${name}.txt.tmpl
5 |
--------------------------------------------------------------------------------
/vendor/github.com/imdario/mergo/go.mod:
--------------------------------------------------------------------------------
1 | module github.com/imdario/mergo
2 |
3 | go 1.13
4 |
5 | require gopkg.in/yaml.v2 v2.3.0
6 |
--------------------------------------------------------------------------------
/vendor/github.com/russross/blackfriday/v2/.gitignore:
--------------------------------------------------------------------------------
1 | *.out
2 | *.swp
3 | *.8
4 | *.6
5 | _obj
6 | _test*
7 | markdown
8 | tags
9 |
--------------------------------------------------------------------------------
/examples/pod/examples.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | name=$(basename ${PWD})
3 | renderizer --testing
4 | renderizer ${name}.yaml.tmpl --testing
5 |
--------------------------------------------------------------------------------
/vendor/gopkg.in/yaml.v2/go.mod:
--------------------------------------------------------------------------------
1 | module gopkg.in/yaml.v2
2 |
3 | go 1.15
4 |
5 | require gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405
6 |
--------------------------------------------------------------------------------
/vendor/github.com/gomatic/clock/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 |
3 | !.gitignore
4 | !.travis.yml
5 | !LICENSE
6 | !*.md
7 | !*.go
8 | !*.mod
9 | !*.sum
10 |
--------------------------------------------------------------------------------
/vendor/github.com/urfave/cli/v2/.gitignore:
--------------------------------------------------------------------------------
1 | *.coverprofile
2 | *.orig
3 | node_modules/
4 | vendor
5 | .idea
6 | internal/*/built-example
7 | coverage.txt
8 |
--------------------------------------------------------------------------------
/test/issues/9f/expect.txt:
--------------------------------------------------------------------------------
1 | map[B:map[C:kills(a,b)]] == map[B:map[C:kills(a,b)]]
2 | map[C:kills(a,b)] == map[C:kills(a,b)]
3 | kills(a,b) == kills(a,b)
4 |
5 |
--------------------------------------------------------------------------------
/examples/README.md:
--------------------------------------------------------------------------------
1 | # Examples
2 |
3 | In each folder, just run:
4 |
5 | renderizer
6 |
7 | The `examples.sh` script shows examples of commands that produce equivalent output.
8 |
--------------------------------------------------------------------------------
/examples/pod/.pod.yaml:
--------------------------------------------------------------------------------
1 | Name: Renderizer
2 | Deployment: master
3 | App: gomatic
4 | Repo: registry.gomatic.systems
5 | BasePort: 101
6 | Containers:
7 | - Name: one
8 | - Name: two
9 |
--------------------------------------------------------------------------------
/vendor/github.com/gomatic/clock/README.md:
--------------------------------------------------------------------------------
1 | # clock
2 |
3 | [](https://travis-ci.org/gomatic/clock)
4 |
5 | Testable `time.Now`
6 |
--------------------------------------------------------------------------------
/vendor/github.com/kardianos/osext/osext_go18.go:
--------------------------------------------------------------------------------
1 | //+build go1.8,!openbsd
2 |
3 | package osext
4 |
5 | import "os"
6 |
7 | func executable() (string, error) {
8 | return os.Executable()
9 | }
10 |
--------------------------------------------------------------------------------
/.env.mk:
--------------------------------------------------------------------------------
1 | ROOT ?= $(shell git rev-parse --show-toplevel)
2 | GOOS := $(shell go env GOOS)
3 | GOARCH := $(shell go env GOARCH)
4 | DIST := $(ROOT)/build/dist/renderizer_$(GOOS)_$(GOARCH)
5 | BINARY := $(DIST)/renderizer
6 |
--------------------------------------------------------------------------------
/vendor/github.com/gomatic/funcmap/go.mod:
--------------------------------------------------------------------------------
1 | module github.com/gomatic/funcmap
2 |
3 | go 1.14
4 |
5 | require (
6 | github.com/gomatic/clock v0.0.0-20180923211445-dd56a80856b5
7 | github.com/stretchr/testify v1.2.2
8 | )
9 |
--------------------------------------------------------------------------------
/examples/environment/environment.txt.tmpl:
--------------------------------------------------------------------------------
1 | # This comes from the environment regardless of user input:
2 | ONLY_ENVIRONMENT {{ environment "ONLY_ENVIRONMENT" }}
3 |
4 | # This can be changed by the caller:
5 | CAN_OVERRIDE {{ .env.CAN_OVERRIDE }}
6 |
--------------------------------------------------------------------------------
/vendor/github.com/imdario/mergo/.deepsource.toml:
--------------------------------------------------------------------------------
1 | version = 1
2 |
3 | test_patterns = [
4 | "*_test.go"
5 | ]
6 |
7 | [[analyzers]]
8 | name = "go"
9 | enabled = true
10 |
11 | [analyzers.meta]
12 | import_path = "github.com/imdario/mergo"
--------------------------------------------------------------------------------
/vendor/github.com/urfave/cli/v2/go.mod:
--------------------------------------------------------------------------------
1 | module github.com/urfave/cli/v2
2 |
3 | go 1.11
4 |
5 | require (
6 | github.com/BurntSushi/toml v0.3.1
7 | github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d
8 | gopkg.in/yaml.v2 v2.2.3
9 | )
10 |
--------------------------------------------------------------------------------
/TODO.md:
--------------------------------------------------------------------------------
1 | - [ ] in-place updates
2 | - URL support
3 | - [ ] settings
4 | - [ ] templates
5 | - input
6 | - [x] templates on stdin
7 | - modes
8 | - [ ] HTML
9 | - [x] text
10 | - functions
11 | - [x] environment
12 | - [x] command_line
13 | - [ ] osquery
14 |
--------------------------------------------------------------------------------
/cmd/renderizer/main_test.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import "testing"
4 |
5 | func Test_main(t *testing.T) {
6 | tests := []struct {
7 | name string
8 | }{
9 | // TODO: Add test cases.
10 | }
11 | for _, tt := range tests {
12 | t.Run(tt.name, func(t *testing.T) {
13 | main()
14 | })
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/examples/environment/examples.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | name=$(basename ${PWD})
3 | export ONLY_ENVIRONMENT=environment
4 | export CAN_OVERRIDE=environment
5 | renderizer
6 | renderizer ${name}.txt.tmpl
7 | renderizer ${name}.txt.tmpl --environment=elsewhere -C --env.CAN_OVERRIDE=command-line --env.ENVIRONMENT=command-line
8 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: go
2 | go:
3 | - "1.14"
4 | - "1.15"
5 | - "tip"
6 | notificaitons:
7 | email:
8 | recipients:
9 | gomatic@nicerobot.org
10 | on_success: change
11 | on_failure: always
12 | install:
13 | - go get -t ./pkg/... ./cmd/...
14 | script:
15 | - go test -v ./pkg/... ./cmd/...
16 |
--------------------------------------------------------------------------------
/vendor/github.com/gomatic/funcmap/.travis.yml:
--------------------------------------------------------------------------------
1 | language: go
2 | go:
3 | - "1.14"
4 | - "1.15"
5 | - "tip"
6 | notificaitons:
7 | email:
8 | recipients:
9 | gomatic@nicerobot.org
10 | on_success: change
11 | on_failure: always
12 | install:
13 | - go get -t ./...
14 | script:
15 | - go test -v
16 |
--------------------------------------------------------------------------------
/vendor/gopkg.in/yaml.v2/.travis.yml:
--------------------------------------------------------------------------------
1 | language: go
2 |
3 | go:
4 | - "1.4.x"
5 | - "1.5.x"
6 | - "1.6.x"
7 | - "1.7.x"
8 | - "1.8.x"
9 | - "1.9.x"
10 | - "1.10.x"
11 | - "1.11.x"
12 | - "1.12.x"
13 | - "1.13.x"
14 | - "1.14.x"
15 | - "tip"
16 |
17 | go_import_path: gopkg.in/yaml.v2
18 |
--------------------------------------------------------------------------------
/go.mod:
--------------------------------------------------------------------------------
1 | module github.com/gomatic/renderizer/v2
2 |
3 | go 1.14
4 |
5 | require (
6 | github.com/gomatic/clock v1.0.0
7 | github.com/gomatic/funcmap v1.0.1
8 | github.com/imdario/mergo v0.3.12
9 | github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0
10 | github.com/urfave/cli/v2 v2.3.0
11 | gopkg.in/yaml.v2 v2.4.0
12 | )
13 |
--------------------------------------------------------------------------------
/vendor/github.com/gomatic/clock/.travis.yml:
--------------------------------------------------------------------------------
1 | language: go
2 | go:
3 | - "1.11"
4 | - "1.12"
5 | - "1.13"
6 | - "1.14"
7 | - "tip"
8 | notificaitons:
9 | email:
10 | recipients:
11 | gomatic@nicerobot.org
12 | on_success: change
13 | on_failure: always
14 | install:
15 | - go get -t ./...
16 | script:
17 | - go test -v
18 |
--------------------------------------------------------------------------------
/vendor/github.com/imdario/mergo/.travis.yml:
--------------------------------------------------------------------------------
1 | language: go
2 | arch:
3 | - amd64
4 | - ppc64le
5 | install:
6 | - go get -t
7 | - go get golang.org/x/tools/cmd/cover
8 | - go get github.com/mattn/goveralls
9 | script:
10 | - go test -race -v ./...
11 | after_script:
12 | - $HOME/gopath/bin/goveralls -service=travis-ci -repotoken $COVERALLS_TOKEN
13 |
--------------------------------------------------------------------------------
/scripts/test-iterate:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -o errexit
4 | set -o nounset
5 |
6 | ROOT="$(git rev-parse --show-toplevel)"
7 |
8 | export RENDERIZER_TESTING=true
9 |
10 | find ${@:-test examples} -name 'expect.sh' -print0 \
11 | | xargs -n1 -0 dirname \
12 | | tr '\n' '\0' \
13 | | xargs -n1 -0 -IDIR "${ROOT}/scripts/test-expect" 'DIR'
14 |
15 | echo success
16 |
--------------------------------------------------------------------------------
/examples/document/document.html.tmpl:
--------------------------------------------------------------------------------
1 |
2 |
3 | {{ with .foo }}
4 | Yay, foo was defined and has value {{ . }}! (Requires --missing=default)
5 | {{ else }}
6 | Boo, foo was not defined. (Requires -m=default.)
7 | {{ end }}
8 |
9 |
10 | {{ range $index, $item := .items }}
11 | - {{ $item }}
12 | {{ end }}
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/vendor/github.com/gomatic/clock/go.mod:
--------------------------------------------------------------------------------
1 | module github.com/gomatic/clock
2 |
3 | go 1.14
4 |
5 | require (
6 | github.com/davecgh/go-spew v1.1.1 // indirect
7 | github.com/pmezard/go-difflib v1.0.0 // indirect
8 | github.com/stretchr/testify v1.2.2
9 | golang.org/x/crypto v0.0.0-20200429183012-4b2356b1ed79 // indirect
10 | golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5 // indirect
11 | )
12 |
--------------------------------------------------------------------------------
/vendor/github.com/imdario/mergo/go.sum:
--------------------------------------------------------------------------------
1 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
2 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
3 | gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
4 | gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
5 |
--------------------------------------------------------------------------------
/.goreleaser-darwin.yml:
--------------------------------------------------------------------------------
1 | project_name: renderizer
2 | builds:
3 | -
4 | binary: renderizer
5 | main: ./cmd/renderizer/main.go
6 | goos:
7 | - darwin
8 | goarch:
9 | - amd64
10 | ldflags: '-s -w -X main.version={{.Version}} -X main.tag={{.Tag}} -X main.commit={{.Commit}} -X main.date={{ time "20060102" }}'
11 |
12 | dist: release/dist
13 |
14 | release:
15 | draft: true
16 |
--------------------------------------------------------------------------------
/vendor/github.com/gomatic/funcmap/README.md:
--------------------------------------------------------------------------------
1 | # funcmap
2 |
3 | [](https://travis-ci.org/gomatic/funcmap)
4 |
5 | Go template functions.
6 |
7 | import "github.com/gomatic/funcmap"
8 |
9 | ...
10 |
11 | template.New(name).
12 | Funcs(funcmap.Map).
13 | Parse(templateSource).
14 | Execute(&result, templateVariables)
15 |
--------------------------------------------------------------------------------
/.version.mk:
--------------------------------------------------------------------------------
1 | VERSION_MAJOR := 2
2 | VERSION_MINOR := 0
3 | VERSION_PATCH := 11
4 |
5 | ifdef BUILD
6 | BUILD := -$(BUILD)
7 | else
8 | BUILD := -$(shell date +%s)
9 | endif
10 |
11 | TAG := v$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)
12 | FULL_VERSION := $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)$(BUILD)
13 | VERSION ?= $(FULL_VERSION)
14 |
15 | export COMMIT_TIME := $(shell git log -n1 --format=%ad --date=format:'%Y%m%dT%H' $(COMMIT_HASH))
16 |
--------------------------------------------------------------------------------
/examples/Makefile:
--------------------------------------------------------------------------------
1 | EXAMPLES = $(patsubst %/,%,$(sort $(dir $(wildcard */*.tmpl))))
2 |
3 | .PHONY : $(EXAMPLES)
4 | .PHONY : run
5 | .PHONY : help
6 | .DEFAULT_GOAL := run
7 |
8 | run: $(EXAMPLES) ## Run all the examples
9 |
10 | $(EXAMPLES):
11 | cd $@; renderizer
12 |
13 | help: ## This help.
14 | @echo EXAMPLES=$(EXAMPLES)
15 | @echo Targets:
16 | @awk 'BEGIN {FS = ":.*?## "} / [#][#] / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
17 |
--------------------------------------------------------------------------------
/vendor/github.com/cpuguy83/go-md2man/v2/md2man/md2man.go:
--------------------------------------------------------------------------------
1 | package md2man
2 |
3 | import (
4 | "github.com/russross/blackfriday/v2"
5 | )
6 |
7 | // Render converts a markdown document into a roff formatted document.
8 | func Render(doc []byte) []byte {
9 | renderer := NewRoffRenderer()
10 |
11 | return blackfriday.Run(doc,
12 | []blackfriday.Option{blackfriday.WithRenderer(renderer),
13 | blackfriday.WithExtensions(renderer.GetExtensions())}...)
14 | }
15 |
--------------------------------------------------------------------------------
/examples/basic/expect.txt:
--------------------------------------------------------------------------------
1 | Hello: Renderizer!
2 | - 0: one
3 | - 1: two
4 | - 2: three
5 |
6 |
7 | Hello: Renderizer!
8 | - 0: one
9 | - 1: two
10 | - 2: three
11 |
12 |
13 | Hello: Renderizer!
14 | - 0: one
15 | - 1: two
16 | - 2: three
17 |
18 |
19 | Hello: Renderizer!
20 | - 0: one
21 | - 1: two
22 | - 2: three
23 |
24 |
25 | Hello: Renderizer!
26 | - 0: one
27 | - 1: two
28 | - 2: three
29 |
30 |
31 | Hello: Renderizer!
32 | - 0: one
33 | - 1: two
34 | - 2: three
35 |
36 |
37 |
--------------------------------------------------------------------------------
/test/test:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | set -o errexit
4 | set -o nounset
5 |
6 | function expect() {
7 | (
8 | cd ${1} || exit ${LINENO}
9 | [ -x examples.sh ] || exit ${LINENO}
10 | [ -f expect.txt ] || exit ${LINENO}
11 |
12 | diff <(./examples.sh) expect.txt || {
13 | pwd
14 | exit 1
15 | }
16 | )
17 | }
18 |
19 | export RENDERIZER_TESTING=true
20 |
21 | for t in issues/*/examples.sh ../examples/*/examples.sh; do
22 | expect $(dirname ${t})
23 | done
24 |
25 | echo success
26 |
--------------------------------------------------------------------------------
/examples/basic/examples.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | name=$(basename ${PWD})
3 | renderizer
4 | renderizer ${name}.txt.tmpl --settings=.${name}.yaml
5 | renderizer ${name}.txt.tmpl --name=Renderizer --items=one --items=two --items=three
6 | renderizer ${name}.txt.tmpl --name=Renderizer --items=one --items=two --items=three --settings=.${name}.yaml
7 | renderizer ${name}.txt.tmpl --settings .${name}.yaml
8 | renderizer ${name}.txt.tmpl --name=Renderizer --items=one --items=two --items=three --settings .${name}.yaml
9 |
--------------------------------------------------------------------------------
/examples/document/examples.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | name=$(basename ${PWD})
3 | renderizer
4 | renderizer ${name}.html.tmpl --settings=.${name}.yaml
5 | renderizer ${name}.html.tmpl --items=apple --items=banana --items=cherry --foo=true
6 | renderizer ${name}.html.tmpl --items=apple --items=banana --items=cherry --foo=true --settings=.${name}.yaml
7 | renderizer ${name}.html.tmpl --settings .${name}.yaml
8 | renderizer ${name}.html.tmpl --items=apple --items=banana --items=cherry --foo=true --settings .${name}.yaml
9 |
--------------------------------------------------------------------------------
/vendor/github.com/shurcooL/sanitized_anchor_name/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: false
2 | language: go
3 | go:
4 | - 1.x
5 | - master
6 | matrix:
7 | allow_failures:
8 | - go: master
9 | fast_finish: true
10 | install:
11 | - # Do nothing. This is needed to prevent default install action "go get -t -v ./..." from happening here (we want it to happen inside script step).
12 | script:
13 | - go get -t -v ./...
14 | - diff -u <(echo -n) <(gofmt -d -s .)
15 | - go tool vet .
16 | - go test -v -race ./...
17 |
--------------------------------------------------------------------------------
/.circleci/config.yml:
--------------------------------------------------------------------------------
1 | # Golang CircleCI 2.0 configuration file
2 | #
3 | # Check https://circleci.com/docs/2.0/language-go/ for more details
4 | version: 2
5 | jobs:
6 | build:
7 | docker:
8 | # specify the version
9 | - image: circleci/golang:1.14
10 |
11 | working_directory: /go/src/github.com/gomatic/renderizer
12 | steps:
13 | - checkout
14 |
15 | # specify any bash command here prefixed with `run: `
16 | - run: go get -v -t -d ./...
17 | - run: go test -v ./...
--------------------------------------------------------------------------------
/vendor/github.com/russross/blackfriday/v2/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: false
2 | language: go
3 | go:
4 | - "1.10.x"
5 | - "1.11.x"
6 | - tip
7 | matrix:
8 | fast_finish: true
9 | allow_failures:
10 | - go: tip
11 | install:
12 | - # Do nothing. This is needed to prevent default install action "go get -t -v ./..." from happening here (we want it to happen inside script step).
13 | script:
14 | - go get -t -v ./...
15 | - diff -u <(echo -n) <(gofmt -d -s .)
16 | - go tool vet .
17 | - go test -v ./...
18 |
--------------------------------------------------------------------------------
/examples/environment/expect.txt:
--------------------------------------------------------------------------------
1 | # This comes from the environment regardless of user input:
2 | ONLY_ENVIRONMENT environment
3 |
4 | # This can be changed by the caller:
5 | CAN_OVERRIDE environment
6 |
7 | # This comes from the environment regardless of user input:
8 | ONLY_ENVIRONMENT environment
9 |
10 | # This can be changed by the caller:
11 | CAN_OVERRIDE environment
12 |
13 | # This comes from the environment regardless of user input:
14 | ONLY_ENVIRONMENT environment
15 |
16 | # This can be changed by the caller:
17 | CAN_OVERRIDE command-line
18 |
19 |
--------------------------------------------------------------------------------
/vendor/github.com/kardianos/osext/osext_plan9.go:
--------------------------------------------------------------------------------
1 | // Copyright 2012 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | //+build !go1.8
6 |
7 | package osext
8 |
9 | import (
10 | "os"
11 | "strconv"
12 | "syscall"
13 | )
14 |
15 | func executable() (string, error) {
16 | f, err := os.Open("/proc/" + strconv.Itoa(os.Getpid()) + "/text")
17 | if err != nil {
18 | return "", err
19 | }
20 | defer f.Close()
21 | return syscall.Fd2path(int(f.Fd()))
22 | }
23 |
--------------------------------------------------------------------------------
/examples/pod/pod.yaml.tmpl:
--------------------------------------------------------------------------------
1 | # Generated: {{now.UTC.Format "2006-01-02T15:04:05MST"}}
2 | # With: {{command_line}}
3 | apiVersion: v1
4 | kind: Pod
5 | metadata:
6 | name: {{replace .Name " " "_" -1 | identifier | lower}}
7 | namespace: {{.App}}-{{.Deployment}}
8 | labels:
9 | app: &app_name {{.App}}
10 | spec:
11 | containers: {{$p := .}}{{range $i, $c := .Containers}}
12 | - name: &name_{{$i}} {{.Name}}
13 | image: {{$p.Repo}}/{{$p.App}}-{{.Name}}
14 | ports:
15 | - name: *name_{{$i}}
16 | containerPort: {{inc $p.BasePort $i}}
17 | protocol: TCP{{end}}
18 |
--------------------------------------------------------------------------------
/vendor/gopkg.in/yaml.v2/NOTICE:
--------------------------------------------------------------------------------
1 | Copyright 2011-2016 Canonical Ltd.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/vendor/github.com/imdario/mergo/.gitignore:
--------------------------------------------------------------------------------
1 | #### joe made this: http://goel.io/joe
2 |
3 | #### go ####
4 | # Binaries for programs and plugins
5 | *.exe
6 | *.dll
7 | *.so
8 | *.dylib
9 |
10 | # Test binary, build with `go test -c`
11 | *.test
12 |
13 | # Output of the go coverage tool, specifically when used with LiteIDE
14 | *.out
15 |
16 | # Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
17 | .glide/
18 |
19 | #### vim ####
20 | # Swap
21 | [._]*.s[a-v][a-z]
22 | [._]*.sw[a-p]
23 | [._]s[a-v][a-z]
24 | [._]sw[a-p]
25 |
26 | # Session
27 | Session.vim
28 |
29 | # Temporary
30 | .netrwhist
31 | *~
32 | # Auto-generated tag files
33 | tags
34 |
--------------------------------------------------------------------------------
/vendor/github.com/urfave/cli/v2/sort.go:
--------------------------------------------------------------------------------
1 | package cli
2 |
3 | import "unicode"
4 |
5 | // lexicographicLess compares strings alphabetically considering case.
6 | func lexicographicLess(i, j string) bool {
7 | iRunes := []rune(i)
8 | jRunes := []rune(j)
9 |
10 | lenShared := len(iRunes)
11 | if lenShared > len(jRunes) {
12 | lenShared = len(jRunes)
13 | }
14 |
15 | for index := 0; index < lenShared; index++ {
16 | ir := iRunes[index]
17 | jr := jRunes[index]
18 |
19 | if lir, ljr := unicode.ToLower(ir), unicode.ToLower(jr); lir != ljr {
20 | return lir < ljr
21 | }
22 |
23 | if ir != jr {
24 | return ir < jr
25 | }
26 | }
27 |
28 | return i < j
29 | }
30 |
--------------------------------------------------------------------------------
/vendor/github.com/russross/blackfriday/v2/esc.go:
--------------------------------------------------------------------------------
1 | package blackfriday
2 |
3 | import (
4 | "html"
5 | "io"
6 | )
7 |
8 | var htmlEscaper = [256][]byte{
9 | '&': []byte("&"),
10 | '<': []byte("<"),
11 | '>': []byte(">"),
12 | '"': []byte("""),
13 | }
14 |
15 | func escapeHTML(w io.Writer, s []byte) {
16 | var start, end int
17 | for end < len(s) {
18 | escSeq := htmlEscaper[s[end]]
19 | if escSeq != nil {
20 | w.Write(s[start:end])
21 | w.Write(escSeq)
22 | start = end + 1
23 | }
24 | end++
25 | }
26 | if start < len(s) && end <= len(s) {
27 | w.Write(s[start:end])
28 | }
29 | }
30 |
31 | func escLink(w io.Writer, text []byte) {
32 | unesc := html.UnescapeString(string(text))
33 | escapeHTML(w, []byte(unesc))
34 | }
35 |
--------------------------------------------------------------------------------
/scripts/test-expect:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -o errexit
4 | set -o nounset
5 |
6 | cd "${1}" || exit ${LINENO}
7 | [ -x expect.sh ] || exit ${LINENO}
8 | [ -f expect.txt ] || exit ${LINENO}
9 |
10 | ROOT="$(git rev-parse --show-toplevel)"
11 | REL="${PWD#${ROOT}/}"
12 |
13 | echo >&2 "testing: ${REL}"
14 |
15 | export RENDERIZER_TESTING=true
16 |
17 | GOOS=$(go env GOOS)
18 | GOARCH=$(go env GOARCH)
19 | DIST="${ROOT}/build/dist/renderizer_${GOOS}_${GOARCH}"
20 | BINARY="${DIST}/renderizer"
21 | [[ -x "${BINARY}" ]] || {
22 | echo >&2 "missing: ${BINARY#${ROOT}/}"
23 | exit 1
24 | }
25 |
26 | export PATH="${DIST}":"${PATH}"
27 |
28 | ./expect.sh | diff -u - expect.txt || {
29 | echo "failed: ${REL} : $(renderizer --version)"
30 | exit 1
31 | } >&2
32 |
33 | exit 0
34 |
--------------------------------------------------------------------------------
/vendor/gopkg.in/yaml.v2/writerc.go:
--------------------------------------------------------------------------------
1 | package yaml
2 |
3 | // Set the writer error and return false.
4 | func yaml_emitter_set_writer_error(emitter *yaml_emitter_t, problem string) bool {
5 | emitter.error = yaml_WRITER_ERROR
6 | emitter.problem = problem
7 | return false
8 | }
9 |
10 | // Flush the output buffer.
11 | func yaml_emitter_flush(emitter *yaml_emitter_t) bool {
12 | if emitter.write_handler == nil {
13 | panic("write handler not set")
14 | }
15 |
16 | // Check if the buffer is empty.
17 | if emitter.buffer_pos == 0 {
18 | return true
19 | }
20 |
21 | if err := emitter.write_handler(emitter, emitter.buffer[:emitter.buffer_pos]); err != nil {
22 | return yaml_emitter_set_writer_error(emitter, "write error: "+err.Error())
23 | }
24 | emitter.buffer_pos = 0
25 | return true
26 | }
27 |
--------------------------------------------------------------------------------
/vendor/github.com/urfave/cli/v2/cli.go:
--------------------------------------------------------------------------------
1 | // Package cli provides a minimal framework for creating and organizing command line
2 | // Go applications. cli is designed to be easy to understand and write, the most simple
3 | // cli application can be written as follows:
4 | // func main() {
5 | // (&cli.App{}).Run(os.Args)
6 | // }
7 | //
8 | // Of course this application does not do much, so let's make this an actual application:
9 | // func main() {
10 | // app := &cli.App{
11 | // Name: "greet",
12 | // Usage: "say a greeting",
13 | // Action: func(c *cli.Context) error {
14 | // fmt.Println("Greetings")
15 | // return nil
16 | // },
17 | // }
18 | //
19 | // app.Run(os.Args)
20 | // }
21 | package cli
22 |
23 | //go:generate go run flag-gen/main.go flag-gen/assets_vfsdata.go
24 |
--------------------------------------------------------------------------------
/vendor/modules.txt:
--------------------------------------------------------------------------------
1 | # github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d
2 | github.com/cpuguy83/go-md2man/v2/md2man
3 | # github.com/gomatic/clock v1.0.0
4 | ## explicit
5 | github.com/gomatic/clock
6 | # github.com/gomatic/funcmap v1.0.1
7 | ## explicit
8 | github.com/gomatic/funcmap
9 | # github.com/imdario/mergo v0.3.12
10 | ## explicit
11 | github.com/imdario/mergo
12 | # github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0
13 | ## explicit
14 | github.com/kardianos/osext
15 | # github.com/russross/blackfriday/v2 v2.0.1
16 | github.com/russross/blackfriday/v2
17 | # github.com/shurcooL/sanitized_anchor_name v1.0.0
18 | github.com/shurcooL/sanitized_anchor_name
19 | # github.com/urfave/cli/v2 v2.3.0
20 | ## explicit
21 | github.com/urfave/cli/v2
22 | # gopkg.in/yaml.v2 v2.4.0
23 | ## explicit
24 | gopkg.in/yaml.v2
25 |
--------------------------------------------------------------------------------
/vendor/github.com/kardianos/osext/README.md:
--------------------------------------------------------------------------------
1 | ### Extensions to the "os" package.
2 |
3 | [](https://godoc.org/github.com/kardianos/osext)
4 |
5 | ## Find the current Executable and ExecutableFolder.
6 |
7 | As of go1.8 the Executable function may be found in `os`. The Executable function
8 | in the std lib `os` package is used if available.
9 |
10 | There is sometimes utility in finding the current executable file
11 | that is running. This can be used for upgrading the current executable
12 | or finding resources located relative to the executable file. Both
13 | working directory and the os.Args[0] value are arbitrary and cannot
14 | be relied on; os.Args[0] can be "faked".
15 |
16 | Multi-platform and supports:
17 | * Linux
18 | * OS X
19 | * Windows
20 | * Plan 9
21 | * BSDs.
22 |
--------------------------------------------------------------------------------
/vendor/github.com/gomatic/funcmap/go.sum:
--------------------------------------------------------------------------------
1 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
2 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3 | github.com/gomatic/clock v0.0.0-20180923211445-dd56a80856b5 h1:WQt/fhqphu76xUeXDZuivs8mIX2SqpeJM6Dl1gwXV9E=
4 | github.com/gomatic/clock v0.0.0-20180923211445-dd56a80856b5/go.mod h1:qMIph1YAd255ac/BLtSwSfcWGQ69BdNuZ/EgkeuQakA=
5 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
6 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
7 | github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A=
8 | github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
9 | github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
10 | github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
11 |
--------------------------------------------------------------------------------
/vendor/github.com/kardianos/osext/osext_windows.go:
--------------------------------------------------------------------------------
1 | // Copyright 2012 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | //+build !go1.8
6 |
7 | package osext
8 |
9 | import (
10 | "syscall"
11 | "unicode/utf16"
12 | "unsafe"
13 | )
14 |
15 | var (
16 | kernel = syscall.MustLoadDLL("kernel32.dll")
17 | getModuleFileNameProc = kernel.MustFindProc("GetModuleFileNameW")
18 | )
19 |
20 | // GetModuleFileName() with hModule = NULL
21 | func executable() (exePath string, err error) {
22 | return getModuleFileName()
23 | }
24 |
25 | func getModuleFileName() (string, error) {
26 | var n uint32
27 | b := make([]uint16, syscall.MAX_PATH)
28 | size := uint32(len(b))
29 |
30 | r0, _, e1 := getModuleFileNameProc.Call(0, uintptr(unsafe.Pointer(&b[0])), uintptr(size))
31 | n = uint32(r0)
32 | if n == 0 {
33 | return "", e1
34 | }
35 | return string(utf16.Decode(b[0:n])), nil
36 | }
37 |
--------------------------------------------------------------------------------
/vendor/github.com/russross/blackfriday/v2/doc.go:
--------------------------------------------------------------------------------
1 | // Package blackfriday is a markdown processor.
2 | //
3 | // It translates plain text with simple formatting rules into an AST, which can
4 | // then be further processed to HTML (provided by Blackfriday itself) or other
5 | // formats (provided by the community).
6 | //
7 | // The simplest way to invoke Blackfriday is to call the Run function. It will
8 | // take a text input and produce a text output in HTML (or other format).
9 | //
10 | // A slightly more sophisticated way to use Blackfriday is to create a Markdown
11 | // processor and to call Parse, which returns a syntax tree for the input
12 | // document. You can leverage Blackfriday's parsing for content extraction from
13 | // markdown documents. You can assign a custom renderer and set various options
14 | // to the Markdown processor.
15 | //
16 | // If you're interested in calling Blackfriday from command line, see
17 | // https://github.com/russross/blackfriday-tool.
18 | package blackfriday
19 |
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | name: goreleaser
2 |
3 | on:
4 | push:
5 | tags:
6 | - '*'
7 |
8 | jobs:
9 | goreleaser:
10 | runs-on: ubuntu-latest
11 | steps:
12 | -
13 | name: Checkout
14 | uses: actions/checkout@v2
15 | with:
16 | fetch-depth: 0
17 | -
18 | name: Set up Go
19 | uses: actions/setup-go@v2
20 | with:
21 | go-version: 1.16
22 | -
23 | name: Import GPG key
24 | id: import_gpg
25 | uses: crazy-max/ghaction-import-gpg@v3
26 | with:
27 | gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
28 | passphrase: ${{ secrets.PASSPHRASE }}
29 | -
30 | name: Run GoReleaser
31 | uses: goreleaser/goreleaser-action@v2
32 | with:
33 | version: latest
34 | args: release --rm-dist
35 | env:
36 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37 | GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
38 |
--------------------------------------------------------------------------------
/vendor/github.com/kardianos/osext/osext.go:
--------------------------------------------------------------------------------
1 | // Copyright 2012 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // Extensions to the standard "os" package.
6 | package osext // import "github.com/kardianos/osext"
7 |
8 | import "path/filepath"
9 |
10 | var cx, ce = executableClean()
11 |
12 | func executableClean() (string, error) {
13 | p, err := executable()
14 | return filepath.Clean(p), err
15 | }
16 |
17 | // Executable returns an absolute path that can be used to
18 | // re-invoke the current program.
19 | // It may not be valid after the current program exits.
20 | func Executable() (string, error) {
21 | return cx, ce
22 | }
23 |
24 | // Returns same path as Executable, returns just the folder
25 | // path. Excludes the executable name and any trailing slash.
26 | func ExecutableFolder() (string, error) {
27 | p, err := Executable()
28 | if err != nil {
29 | return "", err
30 | }
31 |
32 | return filepath.Dir(p), nil
33 | }
34 |
--------------------------------------------------------------------------------
/vendor/github.com/shurcooL/sanitized_anchor_name/main.go:
--------------------------------------------------------------------------------
1 | // Package sanitized_anchor_name provides a func to create sanitized anchor names.
2 | //
3 | // Its logic can be reused by multiple packages to create interoperable anchor names
4 | // and links to those anchors.
5 | //
6 | // At this time, it does not try to ensure that generated anchor names
7 | // are unique, that responsibility falls on the caller.
8 | package sanitized_anchor_name // import "github.com/shurcooL/sanitized_anchor_name"
9 |
10 | import "unicode"
11 |
12 | // Create returns a sanitized anchor name for the given text.
13 | func Create(text string) string {
14 | var anchorName []rune
15 | var futureDash = false
16 | for _, r := range text {
17 | switch {
18 | case unicode.IsLetter(r) || unicode.IsNumber(r):
19 | if futureDash && len(anchorName) > 0 {
20 | anchorName = append(anchorName, '-')
21 | }
22 | futureDash = false
23 | anchorName = append(anchorName, unicode.ToLower(r))
24 | default:
25 | futureDash = true
26 | }
27 | }
28 | return string(anchorName)
29 | }
30 |
--------------------------------------------------------------------------------
/vendor/github.com/gomatic/clock/clock.go:
--------------------------------------------------------------------------------
1 | package clock
2 |
3 | import (
4 | "time"
5 | )
6 |
7 | //
8 | type TimeFunction func() time.Time
9 |
10 | //
11 | type Clock string
12 |
13 | const (
14 | Default = Clock("")
15 | Epoch = Clock("1970-01-01 00:00:00.0 -0000 UTC")
16 | Format = Clock("2006-01-02 15:04:05.987654321 -0000 UTC")
17 | Playground = Clock("2009-11-10 11:00:00.0 -0000 UTC")
18 | NineEleven = Clock("2001-09-11 12:46:40.0 -0000 UTC")
19 | )
20 |
21 | //
22 | func Now(c Clock) TimeFunction {
23 | return c.MustTime()
24 | }
25 |
26 | //
27 | func (c Clock) MustTime() TimeFunction {
28 | f, err := c.Time()
29 | if err != nil {
30 | panic(err)
31 | }
32 | return f
33 | }
34 |
35 | //
36 | func (c Clock) Time() (TimeFunction, error) {
37 | if c == "" {
38 | return time.Now, nil
39 | }
40 | t, err := time.Parse("2006-01-02 15:04:05.999999999 -0700 MST", string(c))
41 | if err != nil {
42 | return time.Now, err
43 | }
44 | return func() time.Time {
45 | return t
46 | }, nil
47 | }
48 |
49 | //
50 | func (c Clock) UTC() TimeFunction {
51 | return c.MustTime()().UTC
52 | }
53 |
--------------------------------------------------------------------------------
/vendor/github.com/shurcooL/sanitized_anchor_name/README.md:
--------------------------------------------------------------------------------
1 | sanitized_anchor_name
2 | =====================
3 |
4 | [](https://travis-ci.org/shurcooL/sanitized_anchor_name) [](https://godoc.org/github.com/shurcooL/sanitized_anchor_name)
5 |
6 | Package sanitized_anchor_name provides a func to create sanitized anchor names.
7 |
8 | Its logic can be reused by multiple packages to create interoperable anchor names
9 | and links to those anchors.
10 |
11 | At this time, it does not try to ensure that generated anchor names
12 | are unique, that responsibility falls on the caller.
13 |
14 | Installation
15 | ------------
16 |
17 | ```bash
18 | go get -u github.com/shurcooL/sanitized_anchor_name
19 | ```
20 |
21 | Example
22 | -------
23 |
24 | ```Go
25 | anchorName := sanitized_anchor_name.Create("This is a header")
26 |
27 | fmt.Println(anchorName)
28 |
29 | // Output:
30 | // this-is-a-header
31 | ```
32 |
33 | License
34 | -------
35 |
36 | - [MIT License](LICENSE)
37 |
--------------------------------------------------------------------------------
/vendor/github.com/kardianos/osext/osext_procfs.go:
--------------------------------------------------------------------------------
1 | // Copyright 2012 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !go1.8,android !go1.8,linux !go1.8,netbsd !go1.8,solaris !go1.8,dragonfly
6 |
7 | package osext
8 |
9 | import (
10 | "errors"
11 | "fmt"
12 | "os"
13 | "runtime"
14 | "strings"
15 | )
16 |
17 | func executable() (string, error) {
18 | switch runtime.GOOS {
19 | case "linux", "android":
20 | const deletedTag = " (deleted)"
21 | execpath, err := os.Readlink("/proc/self/exe")
22 | if err != nil {
23 | return execpath, err
24 | }
25 | execpath = strings.TrimSuffix(execpath, deletedTag)
26 | execpath = strings.TrimPrefix(execpath, deletedTag)
27 | return execpath, nil
28 | case "netbsd":
29 | return os.Readlink("/proc/curproc/exe")
30 | case "dragonfly":
31 | return os.Readlink("/proc/curproc/file")
32 | case "solaris":
33 | return os.Readlink(fmt.Sprintf("/proc/%d/path/a.out", os.Getpid()))
34 | }
35 | return "", errors.New("ExecPath not implemented for " + runtime.GOOS)
36 | }
37 |
--------------------------------------------------------------------------------
/vendor/github.com/cpuguy83/go-md2man/v2/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 Brian Goff
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/vendor/github.com/urfave/cli/v2/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2016 Jeremy Saenz & Contributors
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/vendor/github.com/shurcooL/sanitized_anchor_name/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2015 Dmitri Shuralyov
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/vendor/github.com/urfave/cli/v2/args.go:
--------------------------------------------------------------------------------
1 | package cli
2 |
3 | type Args interface {
4 | // Get returns the nth argument, or else a blank string
5 | Get(n int) string
6 | // First returns the first argument, or else a blank string
7 | First() string
8 | // Tail returns the rest of the arguments (not the first one)
9 | // or else an empty string slice
10 | Tail() []string
11 | // Len returns the length of the wrapped slice
12 | Len() int
13 | // Present checks if there are any arguments present
14 | Present() bool
15 | // Slice returns a copy of the internal slice
16 | Slice() []string
17 | }
18 |
19 | type args []string
20 |
21 | func (a *args) Get(n int) string {
22 | if len(*a) > n {
23 | return (*a)[n]
24 | }
25 | return ""
26 | }
27 |
28 | func (a *args) First() string {
29 | return a.Get(0)
30 | }
31 |
32 | func (a *args) Tail() []string {
33 | if a.Len() >= 2 {
34 | tail := []string((*a)[1:])
35 | ret := make([]string, len(tail))
36 | copy(ret, tail)
37 | return ret
38 | }
39 | return []string{}
40 | }
41 |
42 | func (a *args) Len() int {
43 | return len(*a)
44 | }
45 |
46 | func (a *args) Present() bool {
47 | return a.Len() != 0
48 | }
49 |
50 | func (a *args) Slice() []string {
51 | ret := make([]string, len(*a))
52 | copy(ret, *a)
53 | return ret
54 | }
55 |
--------------------------------------------------------------------------------
/vendor/github.com/urfave/cli/v2/go.sum:
--------------------------------------------------------------------------------
1 | github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
2 | github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
3 | github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
4 | github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
5 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
6 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
7 | github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
8 | github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
9 | github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
10 | github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
11 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
12 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
13 | gopkg.in/yaml.v2 v2.2.3 h1:fvjTMHxHEw/mxHbtzPi3JCcKXQRAnQTBRo6YCJSVHKI=
14 | gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
15 |
--------------------------------------------------------------------------------
/vendor/gopkg.in/yaml.v2/LICENSE.libyaml:
--------------------------------------------------------------------------------
1 | The following files were ported to Go from C files of libyaml, and thus
2 | are still covered by their original copyright and license:
3 |
4 | apic.go
5 | emitterc.go
6 | parserc.go
7 | readerc.go
8 | scannerc.go
9 | writerc.go
10 | yamlh.go
11 | yamlprivateh.go
12 |
13 | Copyright (c) 2006 Kirill Simonov
14 |
15 | Permission is hereby granted, free of charge, to any person obtaining a copy of
16 | this software and associated documentation files (the "Software"), to deal in
17 | the Software without restriction, including without limitation the rights to
18 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
19 | of the Software, and to permit persons to whom the Software is furnished to do
20 | so, subject to the following conditions:
21 |
22 | The above copyright notice and this permission notice shall be included in all
23 | copies or substantial portions of the Software.
24 |
25 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 | SOFTWARE.
32 |
--------------------------------------------------------------------------------
/vendor/github.com/russross/blackfriday/v2/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Blackfriday is distributed under the Simplified BSD License:
2 |
3 | > Copyright © 2011 Russ Ross
4 | > All rights reserved.
5 | >
6 | > Redistribution and use in source and binary forms, with or without
7 | > modification, are permitted provided that the following conditions
8 | > are met:
9 | >
10 | > 1. Redistributions of source code must retain the above copyright
11 | > notice, this list of conditions and the following disclaimer.
12 | >
13 | > 2. Redistributions in binary form must reproduce the above
14 | > copyright notice, this list of conditions and the following
15 | > disclaimer in the documentation and/or other materials provided with
16 | > the distribution.
17 | >
18 | > THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | > "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | > LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 | > FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22 | > COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23 | > INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24 | > BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 | > LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26 | > CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 | > LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
28 | > ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 | > POSSIBILITY OF SUCH DAMAGE.
30 |
--------------------------------------------------------------------------------
/vendor/github.com/kardianos/osext/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2012 The Go Authors. All rights reserved.
2 |
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions are
5 | met:
6 |
7 | * Redistributions of source code must retain the above copyright
8 | notice, this list of conditions and the following disclaimer.
9 | * Redistributions in binary form must reproduce the above
10 | copyright notice, this list of conditions and the following disclaimer
11 | in the documentation and/or other materials provided with the
12 | distribution.
13 | * Neither the name of Google Inc. nor the names of its
14 | contributors may be used to endorse or promote products derived from
15 | this software without specific prior written permission.
16 |
17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
--------------------------------------------------------------------------------
/vendor/github.com/imdario/mergo/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2013 Dario Castañé. All rights reserved.
2 | Copyright (c) 2012 The Go Authors. All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are
6 | met:
7 |
8 | * Redistributions of source code must retain the above copyright
9 | notice, this list of conditions and the following disclaimer.
10 | * Redistributions in binary form must reproduce the above
11 | copyright notice, this list of conditions and the following disclaimer
12 | in the documentation and/or other materials provided with the
13 | distribution.
14 | * Neither the name of Google Inc. nor the names of its
15 | contributors may be used to endorse or promote products derived from
16 | this software without specific prior written permission.
17 |
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | export APP_NAME := $(notdir $(shell pwd))
2 | DESC :=
3 | PROJECT_URL := "https://github.com/gomatic/$(APP_NAME)"
4 |
5 | ROOT := $(shell git rev-parse --show-toplevel)
6 | include $(ROOT)/.env.mk
7 | include $(ROOT)/.version.mk
8 |
9 | #
10 |
11 | PREFIX ?= usr/local
12 |
13 | #
14 |
15 | .PHONY : all release snapshot vet test examples tag
16 | .PHONY : help
17 | .DEFAULT_GOAL := snapshot
18 |
19 | #
20 |
21 | ALL_SOURCES = $(filter-out vendor/%, $(wildcard *.go */*.go */*/*.go))
22 | MAIN_SOURCES = $(filter-out %_test.go, $(ALL_SOURCES))
23 | TEST_SOURCES = $(filter %_test.go, $(ALL_SOURCES))
24 |
25 | #
26 |
27 | build snapshot: vet test $(BINARY) # Build snapshot
28 |
29 | all: release ## Make everything
30 |
31 | $(BINARY): $(MAIN_SOURCES)
32 | goreleaser --snapshot --rm-dist --skip-publish --skip-validate
33 |
34 | release: vet test ## Build releases
35 | $(MAKE) full-release BUILD=
36 |
37 | full-release: tag
38 | goreleaser --rm-dist --skip-publish
39 |
40 | tag:
41 | git tag -f -m $(TAG) $(TAG)
42 |
43 | vet test: ## Run tests or vet
44 | go $@ ./...
45 |
46 | tests examples: snapshot
47 | @scripts/test-iterate test examples
48 |
49 | clean:
50 | rm -rf build
51 |
52 | help: ## This help.
53 | @echo $(APP_NAME)
54 | @echo MAIN_SOURCES=$(MAIN_SOURCES)
55 | @echo TEST_SOURCES=$(TEST_SOURCES)
56 | @echo BUILD=$(BUILD)
57 | @echo FULL_VERSION=$(FULL_VERSION)
58 | @echo ROOT=$(ROOT)
59 | @echo GOOS=$(GOOS)
60 | @echo GOARCH=$(GOARCH)
61 | @echo DIST=$(DIST)
62 | @echo BINARY=$(BINARY)
63 | @echo VERSION=$(VERSION)
64 | @echo Targets:
65 | @awk 'BEGIN {FS = ":.*?## "} / [#][#] / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
66 |
--------------------------------------------------------------------------------
/examples/document/expect.txt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Yay, foo was defined and has value true! (Requires --missing=default)
5 |
6 |
7 |
8 |
9 | - apple
10 |
11 | - banana
12 |
13 | - cherry
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 | Yay, foo was defined and has value true! (Requires --missing=default)
24 |
25 |
26 |
27 |
28 | - apple
29 |
30 | - banana
31 |
32 | - cherry
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 | Yay, foo was defined and has value true! (Requires --missing=default)
43 |
44 |
45 |
46 |
47 | - apple
48 |
49 | - banana
50 |
51 | - cherry
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 | Yay, foo was defined and has value true! (Requires --missing=default)
62 |
63 |
64 |
65 |
66 | - apple
67 |
68 | - banana
69 |
70 | - cherry
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 | Yay, foo was defined and has value true! (Requires --missing=default)
81 |
82 |
83 |
84 |
85 | - apple
86 |
87 | - banana
88 |
89 | - cherry
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 | Yay, foo was defined and has value true! (Requires --missing=default)
100 |
101 |
102 |
103 |
104 | - apple
105 |
106 | - banana
107 |
108 | - cherry
109 |
110 |
111 |
112 |
113 |
114 |
115 |
--------------------------------------------------------------------------------
/vendor/github.com/gomatic/clock/go.sum:
--------------------------------------------------------------------------------
1 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
2 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
4 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
5 | github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
6 | github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
7 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
8 | golang.org/x/crypto v0.0.0-20200429183012-4b2356b1ed79 h1:IaQbIIB2X/Mp/DKctl6ROxz1KyMlKp4uyvL6+kQ7C88=
9 | golang.org/x/crypto v0.0.0-20200429183012-4b2356b1ed79/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
10 | golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
11 | golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5 h1:WQ8q63x+f/zpC8Ac1s9wLElVoHhm32p6tudrU72n1QA=
12 | golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
13 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
14 | golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
15 | golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884=
16 | golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
17 | golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
18 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
19 |
--------------------------------------------------------------------------------
/vendor/github.com/urfave/cli/v2/funcs.go:
--------------------------------------------------------------------------------
1 | package cli
2 |
3 | // BashCompleteFunc is an action to execute when the shell completion flag is set
4 | type BashCompleteFunc func(*Context)
5 |
6 | // BeforeFunc is an action to execute before any subcommands are run, but after
7 | // the context is ready if a non-nil error is returned, no subcommands are run
8 | type BeforeFunc func(*Context) error
9 |
10 | // AfterFunc is an action to execute after any subcommands are run, but after the
11 | // subcommand has finished it is run even if Action() panics
12 | type AfterFunc func(*Context) error
13 |
14 | // ActionFunc is the action to execute when no subcommands are specified
15 | type ActionFunc func(*Context) error
16 |
17 | // CommandNotFoundFunc is executed if the proper command cannot be found
18 | type CommandNotFoundFunc func(*Context, string)
19 |
20 | // OnUsageErrorFunc is executed if an usage error occurs. This is useful for displaying
21 | // customized usage error messages. This function is able to replace the
22 | // original error messages. If this function is not set, the "Incorrect usage"
23 | // is displayed and the execution is interrupted.
24 | type OnUsageErrorFunc func(context *Context, err error, isSubcommand bool) error
25 |
26 | // ExitErrHandlerFunc is executed if provided in order to handle exitError values
27 | // returned by Actions and Before/After functions.
28 | type ExitErrHandlerFunc func(context *Context, err error)
29 |
30 | // FlagStringFunc is used by the help generation to display a flag, which is
31 | // expected to be a single line.
32 | type FlagStringFunc func(Flag) string
33 |
34 | // FlagNamePrefixFunc is used by the default FlagStringFunc to create prefix
35 | // text for a flag's full name.
36 | type FlagNamePrefixFunc func(fullName []string, placeholder string) string
37 |
38 | // FlagEnvHintFunc is used by the default FlagStringFunc to annotate flag help
39 | // with the environment variable details.
40 | type FlagEnvHintFunc func(envVars []string, str string) string
41 |
42 | // FlagFileHintFunc is used by the default FlagStringFunc to annotate flag help
43 | // with the file path details.
44 | type FlagFileHintFunc func(filePath, str string) string
45 |
--------------------------------------------------------------------------------
/vendor/github.com/urfave/cli/v2/category.go:
--------------------------------------------------------------------------------
1 | package cli
2 |
3 | // CommandCategories interface allows for category manipulation
4 | type CommandCategories interface {
5 | // AddCommand adds a command to a category, creating a new category if necessary.
6 | AddCommand(category string, command *Command)
7 | // categories returns a copy of the category slice
8 | Categories() []CommandCategory
9 | }
10 |
11 | type commandCategories []*commandCategory
12 |
13 | func newCommandCategories() CommandCategories {
14 | ret := commandCategories([]*commandCategory{})
15 | return &ret
16 | }
17 |
18 | func (c *commandCategories) Less(i, j int) bool {
19 | return lexicographicLess((*c)[i].Name(), (*c)[j].Name())
20 | }
21 |
22 | func (c *commandCategories) Len() int {
23 | return len(*c)
24 | }
25 |
26 | func (c *commandCategories) Swap(i, j int) {
27 | (*c)[i], (*c)[j] = (*c)[j], (*c)[i]
28 | }
29 |
30 | func (c *commandCategories) AddCommand(category string, command *Command) {
31 | for _, commandCategory := range []*commandCategory(*c) {
32 | if commandCategory.name == category {
33 | commandCategory.commands = append(commandCategory.commands, command)
34 | return
35 | }
36 | }
37 | newVal := append(*c,
38 | &commandCategory{name: category, commands: []*Command{command}})
39 | *c = newVal
40 | }
41 |
42 | func (c *commandCategories) Categories() []CommandCategory {
43 | ret := make([]CommandCategory, len(*c))
44 | for i, cat := range *c {
45 | ret[i] = cat
46 | }
47 | return ret
48 | }
49 |
50 | // CommandCategory is a category containing commands.
51 | type CommandCategory interface {
52 | // Name returns the category name string
53 | Name() string
54 | // VisibleCommands returns a slice of the Commands with Hidden=false
55 | VisibleCommands() []*Command
56 | }
57 |
58 | type commandCategory struct {
59 | name string
60 | commands []*Command
61 | }
62 |
63 | func (c *commandCategory) Name() string {
64 | return c.name
65 | }
66 |
67 | func (c *commandCategory) VisibleCommands() []*Command {
68 | if c.commands == nil {
69 | c.commands = []*Command{}
70 | }
71 |
72 | var ret []*Command
73 | for _, command := range c.commands {
74 | if !command.Hidden {
75 | ret = append(ret, command)
76 | }
77 | }
78 | return ret
79 | }
80 |
--------------------------------------------------------------------------------
/vendor/github.com/urfave/cli/v2/README.md:
--------------------------------------------------------------------------------
1 | cli
2 | ===
3 |
4 | [](https://godoc.org/github.com/urfave/cli)
5 | [](https://codebeat.co/projects/github-com-urfave-cli)
6 | [](https://goreportcard.com/report/urfave/cli)
7 | [](https://codecov.io/gh/urfave/cli)
8 |
9 | cli is a simple, fast, and fun package for building command line apps in Go. The
10 | goal is to enable developers to write fast and distributable command line
11 | applications in an expressive way.
12 |
13 | ## Usage Documentation
14 |
15 | Usage documentation exists for each major version. Don't know what version you're on? You're probably using the version from the `master` branch, which is currently `v2`.
16 |
17 | - `v2` - [./docs/v2/manual.md](./docs/v2/manual.md)
18 | - `v1` - [./docs/v1/manual.md](./docs/v1/manual.md)
19 |
20 | Guides for migrating to newer versions:
21 |
22 | - `v1-to-v2` - [./docs/migrate-v1-to-v2.md](./docs/migrate-v1-to-v2.md)
23 |
24 | ## Installation
25 |
26 | Using this package requires a working Go environment. [See the install instructions for Go](http://golang.org/doc/install.html).
27 |
28 | Go Modules are required when using this package. [See the go blog guide on using Go Modules](https://blog.golang.org/using-go-modules).
29 |
30 | ### Using `v2` releases
31 |
32 | ```
33 | $ GO111MODULE=on go get github.com/urfave/cli/v2
34 | ```
35 |
36 | ```go
37 | ...
38 | import (
39 | "github.com/urfave/cli/v2" // imports as package "cli"
40 | )
41 | ...
42 | ```
43 |
44 | ### Using `v1` releases
45 |
46 | ```
47 | $ GO111MODULE=on go get github.com/urfave/cli
48 | ```
49 |
50 | ```go
51 | ...
52 | import (
53 | "github.com/urfave/cli"
54 | )
55 | ...
56 | ```
57 |
58 | ### GOPATH
59 |
60 | Make sure your `PATH` includes the `$GOPATH/bin` directory so your commands can
61 | be easily used:
62 | ```
63 | export PATH=$PATH:$GOPATH/bin
64 | ```
65 |
66 | ### Supported platforms
67 |
68 | cli is tested against multiple versions of Go on Linux, and against the latest
69 | released version of Go on OS X and Windows. This project uses Github Actions for
70 | builds. To see our currently supported go versions and platforms, look at the [./.github/workflows/cli.yml](https://github.com/urfave/cli/blob/master/.github/workflows/cli.yml).
71 |
--------------------------------------------------------------------------------
/vendor/github.com/urfave/cli/v2/flag_path.go:
--------------------------------------------------------------------------------
1 | package cli
2 |
3 | import "flag"
4 |
5 | type PathFlag struct {
6 | Name string
7 | Aliases []string
8 | Usage string
9 | EnvVars []string
10 | FilePath string
11 | Required bool
12 | Hidden bool
13 | TakesFile bool
14 | Value string
15 | DefaultText string
16 | Destination *string
17 | HasBeenSet bool
18 | }
19 |
20 | // IsSet returns whether or not the flag has been set through env or file
21 | func (f *PathFlag) IsSet() bool {
22 | return f.HasBeenSet
23 | }
24 |
25 | // String returns a readable representation of this value
26 | // (for usage defaults)
27 | func (f *PathFlag) String() string {
28 | return FlagStringer(f)
29 | }
30 |
31 | // Names returns the names of the flag
32 | func (f *PathFlag) Names() []string {
33 | return flagNames(f.Name, f.Aliases)
34 | }
35 |
36 | // IsRequired returns whether or not the flag is required
37 | func (f *PathFlag) IsRequired() bool {
38 | return f.Required
39 | }
40 |
41 | // TakesValue returns true of the flag takes a value, otherwise false
42 | func (f *PathFlag) TakesValue() bool {
43 | return true
44 | }
45 |
46 | // GetUsage returns the usage string for the flag
47 | func (f *PathFlag) GetUsage() string {
48 | return f.Usage
49 | }
50 |
51 | // GetValue returns the flags value as string representation and an empty
52 | // string if the flag takes no value at all.
53 | func (f *PathFlag) GetValue() string {
54 | return f.Value
55 | }
56 |
57 | // Apply populates the flag given the flag set and environment
58 | func (f *PathFlag) Apply(set *flag.FlagSet) error {
59 | if val, ok := flagFromEnvOrFile(f.EnvVars, f.FilePath); ok {
60 | f.Value = val
61 | f.HasBeenSet = true
62 | }
63 |
64 | for _, name := range f.Names() {
65 | if f.Destination != nil {
66 | set.StringVar(f.Destination, name, f.Value, f.Usage)
67 | continue
68 | }
69 | set.String(name, f.Value, f.Usage)
70 | }
71 |
72 | return nil
73 | }
74 |
75 | // Path looks up the value of a local PathFlag, returns
76 | // "" if not found
77 | func (c *Context) Path(name string) string {
78 | if fs := lookupFlagSet(name, c); fs != nil {
79 | return lookupPath(name, fs)
80 | }
81 |
82 | return ""
83 | }
84 |
85 | func lookupPath(name string, set *flag.FlagSet) string {
86 | f := set.Lookup(name)
87 | if f != nil {
88 | parsed, err := f.Value.String(), error(nil)
89 | if err != nil {
90 | return ""
91 | }
92 | return parsed
93 | }
94 | return ""
95 | }
96 |
--------------------------------------------------------------------------------
/vendor/github.com/urfave/cli/v2/flag_string.go:
--------------------------------------------------------------------------------
1 | package cli
2 |
3 | import "flag"
4 |
5 | // StringFlag is a flag with type string
6 | type StringFlag struct {
7 | Name string
8 | Aliases []string
9 | Usage string
10 | EnvVars []string
11 | FilePath string
12 | Required bool
13 | Hidden bool
14 | TakesFile bool
15 | Value string
16 | DefaultText string
17 | Destination *string
18 | HasBeenSet bool
19 | }
20 |
21 | // IsSet returns whether or not the flag has been set through env or file
22 | func (f *StringFlag) IsSet() bool {
23 | return f.HasBeenSet
24 | }
25 |
26 | // String returns a readable representation of this value
27 | // (for usage defaults)
28 | func (f *StringFlag) String() string {
29 | return FlagStringer(f)
30 | }
31 |
32 | // Names returns the names of the flag
33 | func (f *StringFlag) Names() []string {
34 | return flagNames(f.Name, f.Aliases)
35 | }
36 |
37 | // IsRequired returns whether or not the flag is required
38 | func (f *StringFlag) IsRequired() bool {
39 | return f.Required
40 | }
41 |
42 | // TakesValue returns true of the flag takes a value, otherwise false
43 | func (f *StringFlag) TakesValue() bool {
44 | return true
45 | }
46 |
47 | // GetUsage returns the usage string for the flag
48 | func (f *StringFlag) GetUsage() string {
49 | return f.Usage
50 | }
51 |
52 | // GetValue returns the flags value as string representation and an empty
53 | // string if the flag takes no value at all.
54 | func (f *StringFlag) GetValue() string {
55 | return f.Value
56 | }
57 |
58 | // Apply populates the flag given the flag set and environment
59 | func (f *StringFlag) Apply(set *flag.FlagSet) error {
60 | if val, ok := flagFromEnvOrFile(f.EnvVars, f.FilePath); ok {
61 | f.Value = val
62 | f.HasBeenSet = true
63 | }
64 |
65 | for _, name := range f.Names() {
66 | if f.Destination != nil {
67 | set.StringVar(f.Destination, name, f.Value, f.Usage)
68 | continue
69 | }
70 | set.String(name, f.Value, f.Usage)
71 | }
72 |
73 | return nil
74 | }
75 |
76 | // String looks up the value of a local StringFlag, returns
77 | // "" if not found
78 | func (c *Context) String(name string) string {
79 | if fs := lookupFlagSet(name, c); fs != nil {
80 | return lookupString(name, fs)
81 | }
82 | return ""
83 | }
84 |
85 | func lookupString(name string, set *flag.FlagSet) string {
86 | f := set.Lookup(name)
87 | if f != nil {
88 | parsed, err := f.Value.String(), error(nil)
89 | if err != nil {
90 | return ""
91 | }
92 | return parsed
93 | }
94 | return ""
95 | }
96 |
--------------------------------------------------------------------------------
/vendor/github.com/imdario/mergo/mergo.go:
--------------------------------------------------------------------------------
1 | // Copyright 2013 Dario Castañé. All rights reserved.
2 | // Copyright 2009 The Go Authors. All rights reserved.
3 | // Use of this source code is governed by a BSD-style
4 | // license that can be found in the LICENSE file.
5 |
6 | // Based on src/pkg/reflect/deepequal.go from official
7 | // golang's stdlib.
8 |
9 | package mergo
10 |
11 | import (
12 | "errors"
13 | "reflect"
14 | )
15 |
16 | // Errors reported by Mergo when it finds invalid arguments.
17 | var (
18 | ErrNilArguments = errors.New("src and dst must not be nil")
19 | ErrDifferentArgumentsTypes = errors.New("src and dst must be of same type")
20 | ErrNotSupported = errors.New("only structs and maps are supported")
21 | ErrExpectedMapAsDestination = errors.New("dst was expected to be a map")
22 | ErrExpectedStructAsDestination = errors.New("dst was expected to be a struct")
23 | ErrNonPointerAgument = errors.New("dst must be a pointer")
24 | )
25 |
26 | // During deepMerge, must keep track of checks that are
27 | // in progress. The comparison algorithm assumes that all
28 | // checks in progress are true when it reencounters them.
29 | // Visited are stored in a map indexed by 17 * a1 + a2;
30 | type visit struct {
31 | ptr uintptr
32 | typ reflect.Type
33 | next *visit
34 | }
35 |
36 | // From src/pkg/encoding/json/encode.go.
37 | func isEmptyValue(v reflect.Value) bool {
38 | switch v.Kind() {
39 | case reflect.Array, reflect.Map, reflect.Slice, reflect.String:
40 | return v.Len() == 0
41 | case reflect.Bool:
42 | return !v.Bool()
43 | case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
44 | return v.Int() == 0
45 | case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
46 | return v.Uint() == 0
47 | case reflect.Float32, reflect.Float64:
48 | return v.Float() == 0
49 | case reflect.Interface, reflect.Ptr:
50 | if v.IsNil() {
51 | return true
52 | }
53 | return isEmptyValue(v.Elem())
54 | case reflect.Func:
55 | return v.IsNil()
56 | case reflect.Invalid:
57 | return true
58 | }
59 | return false
60 | }
61 |
62 | func resolveValues(dst, src interface{}) (vDst, vSrc reflect.Value, err error) {
63 | if dst == nil || src == nil {
64 | err = ErrNilArguments
65 | return
66 | }
67 | vDst = reflect.ValueOf(dst).Elem()
68 | if vDst.Kind() != reflect.Struct && vDst.Kind() != reflect.Map {
69 | err = ErrNotSupported
70 | return
71 | }
72 | vSrc = reflect.ValueOf(src)
73 | // We check if vSrc is a pointer to dereference it.
74 | if vSrc.Kind() == reflect.Ptr {
75 | vSrc = vSrc.Elem()
76 | }
77 | return
78 | }
79 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # renderizer
2 |
3 | [](https://travis-ci.org/gomatic/renderizer)
4 |
5 | Render Go text templates from the command line.
6 |
7 | go get github.com/gomatic/renderizer/v2/cmd/renderizer
8 |
9 | Supports providing top-level name/value pairs on the command line:
10 |
11 | echo 'Hello, {{.User}}' | renderizer --user=${USER}
12 |
13 | And read from the environment:
14 |
15 | echo 'Hello, {{.env.USER}}' | renderizer
16 |
17 | ## Usage:
18 |
19 | renderizer [OPTIONS] [--name=value]... [template-file]...
20 |
21 | ## Examples
22 |
23 | Render the `pod.yaml.tmpl` using values from `examples/pod/.renderizer.yaml`:
24 |
25 | renderizer --settings=examples/pod/.pod.yaml examples/pod/pod.yaml.tmpl
26 |
27 | Or set `RENDERIZER` in the environment:
28 |
29 | RENDERIZER=examples/.pod.yaml renderizer examples/pod/pod.yaml.tmpl
30 |
31 | Alternatively, it'll try `.pod.yaml` in the current directory.
32 |
33 | (cd examples/pod; renderizer)
34 |
35 | Next, override the `deployment` value to render the "dev" `pod.yaml.tmpl` (after `cd examples/pod`):
36 |
37 | renderizer --deployment=dev --name='spaced out'
38 |
39 | For more examples, see the [`examples`](examples) folder.
40 |
41 | # Configuration
42 |
43 | ### Settings
44 |
45 | Settings can be loaded from any YAMLs:
46 |
47 | renderizer --settings=.settings1.yaml --settings=.settings2.yaml --name=value template-file
48 |
49 | ### Capitalization `-C`
50 |
51 | This is a positional toggle flag.
52 |
53 | Variable names are converted to title case by default. It can be disabled for any subsequent variables:
54 |
55 | renderizer --name=value -C --top=first template-file
56 |
57 | Sets:
58 |
59 | Name: value
60 | top: first
61 |
62 | ### Missing Keys
63 |
64 | Control the missingkeys template-engine option:
65 |
66 | renderizer --missing=zero --top=first template-file
67 |
68 | ### Environment
69 |
70 | Provide a name for the environment variables:
71 |
72 | renderizer --environment=env template-file
73 |
74 | It defaults to `env` which is effectively the same as the above `--environment=env`.
75 |
76 | ## Template Functions
77 |
78 | For the full list, see [functions.txt.tmpl](examples/functions/functions.txt.tmpl)
79 |
80 | - `add` - `func(a, b int) int`
81 | - `cleanse` - `func(s string) string` - remove `[^[:alpha:]]`
82 | - `commandLine` - `func() string` the command line
83 | - `environment` - `map[string]string` - the runtime environment
84 | - `inc` - `func(a int) int`
85 | - `join` - `func(a []interface, sep string) string`
86 | - `lower` - `strings.ToLower`
87 | - `now` - `time.Now`
88 | - `replace` - `strings.Replace`
89 | - `trim` - `strings.Trim`
90 | - `trimLeft` - `strings.TrimLeft`
91 | - `trimRight` - `strings.TrimRight`
92 | - `upper` - `strings.ToUpper`
93 |
--------------------------------------------------------------------------------
/vendor/github.com/urfave/cli/v2/flag_bool.go:
--------------------------------------------------------------------------------
1 | package cli
2 |
3 | import (
4 | "flag"
5 | "fmt"
6 | "strconv"
7 | )
8 |
9 | // BoolFlag is a flag with type bool
10 | type BoolFlag struct {
11 | Name string
12 | Aliases []string
13 | Usage string
14 | EnvVars []string
15 | FilePath string
16 | Required bool
17 | Hidden bool
18 | Value bool
19 | DefaultText string
20 | Destination *bool
21 | HasBeenSet bool
22 | }
23 |
24 | // IsSet returns whether or not the flag has been set through env or file
25 | func (f *BoolFlag) IsSet() bool {
26 | return f.HasBeenSet
27 | }
28 |
29 | // String returns a readable representation of this value
30 | // (for usage defaults)
31 | func (f *BoolFlag) String() string {
32 | return FlagStringer(f)
33 | }
34 |
35 | // Names returns the names of the flag
36 | func (f *BoolFlag) Names() []string {
37 | return flagNames(f.Name, f.Aliases)
38 | }
39 |
40 | // IsRequired returns whether or not the flag is required
41 | func (f *BoolFlag) IsRequired() bool {
42 | return f.Required
43 | }
44 |
45 | // TakesValue returns true of the flag takes a value, otherwise false
46 | func (f *BoolFlag) TakesValue() bool {
47 | return false
48 | }
49 |
50 | // GetUsage returns the usage string for the flag
51 | func (f *BoolFlag) GetUsage() string {
52 | return f.Usage
53 | }
54 |
55 | // GetValue returns the flags value as string representation and an empty
56 | // string if the flag takes no value at all.
57 | func (f *BoolFlag) GetValue() string {
58 | return ""
59 | }
60 |
61 | // Apply populates the flag given the flag set and environment
62 | func (f *BoolFlag) Apply(set *flag.FlagSet) error {
63 | if val, ok := flagFromEnvOrFile(f.EnvVars, f.FilePath); ok {
64 | if val != "" {
65 | valBool, err := strconv.ParseBool(val)
66 |
67 | if err != nil {
68 | return fmt.Errorf("could not parse %q as bool value for flag %s: %s", val, f.Name, err)
69 | }
70 |
71 | f.Value = valBool
72 | f.HasBeenSet = true
73 | }
74 | }
75 |
76 | for _, name := range f.Names() {
77 | if f.Destination != nil {
78 | set.BoolVar(f.Destination, name, f.Value, f.Usage)
79 | continue
80 | }
81 | set.Bool(name, f.Value, f.Usage)
82 | }
83 |
84 | return nil
85 | }
86 |
87 | // Bool looks up the value of a local BoolFlag, returns
88 | // false if not found
89 | func (c *Context) Bool(name string) bool {
90 | if fs := lookupFlagSet(name, c); fs != nil {
91 | return lookupBool(name, fs)
92 | }
93 | return false
94 | }
95 |
96 | func lookupBool(name string, set *flag.FlagSet) bool {
97 | f := set.Lookup(name)
98 | if f != nil {
99 | parsed, err := strconv.ParseBool(f.Value.String())
100 | if err != nil {
101 | return false
102 | }
103 | return parsed
104 | }
105 | return false
106 | }
107 |
--------------------------------------------------------------------------------
/vendor/github.com/urfave/cli/v2/flag_int.go:
--------------------------------------------------------------------------------
1 | package cli
2 |
3 | import (
4 | "flag"
5 | "fmt"
6 | "strconv"
7 | )
8 |
9 | // IntFlag is a flag with type int
10 | type IntFlag struct {
11 | Name string
12 | Aliases []string
13 | Usage string
14 | EnvVars []string
15 | FilePath string
16 | Required bool
17 | Hidden bool
18 | Value int
19 | DefaultText string
20 | Destination *int
21 | HasBeenSet bool
22 | }
23 |
24 | // IsSet returns whether or not the flag has been set through env or file
25 | func (f *IntFlag) IsSet() bool {
26 | return f.HasBeenSet
27 | }
28 |
29 | // String returns a readable representation of this value
30 | // (for usage defaults)
31 | func (f *IntFlag) String() string {
32 | return FlagStringer(f)
33 | }
34 |
35 | // Names returns the names of the flag
36 | func (f *IntFlag) Names() []string {
37 | return flagNames(f.Name, f.Aliases)
38 | }
39 |
40 | // IsRequired returns whether or not the flag is required
41 | func (f *IntFlag) IsRequired() bool {
42 | return f.Required
43 | }
44 |
45 | // TakesValue returns true of the flag takes a value, otherwise false
46 | func (f *IntFlag) TakesValue() bool {
47 | return true
48 | }
49 |
50 | // GetUsage returns the usage string for the flag
51 | func (f *IntFlag) GetUsage() string {
52 | return f.Usage
53 | }
54 |
55 | // GetValue returns the flags value as string representation and an empty
56 | // string if the flag takes no value at all.
57 | func (f *IntFlag) GetValue() string {
58 | return fmt.Sprintf("%d", f.Value)
59 | }
60 |
61 | // Apply populates the flag given the flag set and environment
62 | func (f *IntFlag) Apply(set *flag.FlagSet) error {
63 | if val, ok := flagFromEnvOrFile(f.EnvVars, f.FilePath); ok {
64 | if val != "" {
65 | valInt, err := strconv.ParseInt(val, 0, 64)
66 |
67 | if err != nil {
68 | return fmt.Errorf("could not parse %q as int value for flag %s: %s", val, f.Name, err)
69 | }
70 |
71 | f.Value = int(valInt)
72 | f.HasBeenSet = true
73 | }
74 | }
75 |
76 | for _, name := range f.Names() {
77 | if f.Destination != nil {
78 | set.IntVar(f.Destination, name, f.Value, f.Usage)
79 | continue
80 | }
81 | set.Int(name, f.Value, f.Usage)
82 | }
83 |
84 | return nil
85 | }
86 |
87 | // Int looks up the value of a local IntFlag, returns
88 | // 0 if not found
89 | func (c *Context) Int(name string) int {
90 | if fs := lookupFlagSet(name, c); fs != nil {
91 | return lookupInt(name, fs)
92 | }
93 | return 0
94 | }
95 |
96 | func lookupInt(name string, set *flag.FlagSet) int {
97 | f := set.Lookup(name)
98 | if f != nil {
99 | parsed, err := strconv.ParseInt(f.Value.String(), 0, 64)
100 | if err != nil {
101 | return 0
102 | }
103 | return int(parsed)
104 | }
105 | return 0
106 | }
107 |
--------------------------------------------------------------------------------
/vendor/github.com/urfave/cli/v2/parse.go:
--------------------------------------------------------------------------------
1 | package cli
2 |
3 | import (
4 | "flag"
5 | "strings"
6 | )
7 |
8 | type iterativeParser interface {
9 | newFlagSet() (*flag.FlagSet, error)
10 | useShortOptionHandling() bool
11 | }
12 |
13 | // To enable short-option handling (e.g., "-it" vs "-i -t") we have to
14 | // iteratively catch parsing errors. This way we achieve LR parsing without
15 | // transforming any arguments. Otherwise, there is no way we can discriminate
16 | // combined short options from common arguments that should be left untouched.
17 | // Pass `shellComplete` to continue parsing options on failure during shell
18 | // completion when, the user-supplied options may be incomplete.
19 | func parseIter(set *flag.FlagSet, ip iterativeParser, args []string, shellComplete bool) error {
20 | for {
21 | err := set.Parse(args)
22 | if !ip.useShortOptionHandling() || err == nil {
23 | if shellComplete {
24 | return nil
25 | }
26 | return err
27 | }
28 |
29 | errStr := err.Error()
30 | trimmed := strings.TrimPrefix(errStr, "flag provided but not defined: -")
31 | if errStr == trimmed {
32 | return err
33 | }
34 |
35 | // regenerate the initial args with the split short opts
36 | argsWereSplit := false
37 | for i, arg := range args {
38 | // skip args that are not part of the error message
39 | if name := strings.TrimLeft(arg, "-"); name != trimmed {
40 | continue
41 | }
42 |
43 | // if we can't split, the error was accurate
44 | shortOpts := splitShortOptions(set, arg)
45 | if len(shortOpts) == 1 {
46 | return err
47 | }
48 |
49 | // swap current argument with the split version
50 | args = append(args[:i], append(shortOpts, args[i+1:]...)...)
51 | argsWereSplit = true
52 | break
53 | }
54 |
55 | // This should be an impossible to reach code path, but in case the arg
56 | // splitting failed to happen, this will prevent infinite loops
57 | if !argsWereSplit {
58 | return err
59 | }
60 |
61 | // Since custom parsing failed, replace the flag set before retrying
62 | newSet, err := ip.newFlagSet()
63 | if err != nil {
64 | return err
65 | }
66 | *set = *newSet
67 | }
68 | }
69 |
70 | func splitShortOptions(set *flag.FlagSet, arg string) []string {
71 | shortFlagsExist := func(s string) bool {
72 | for _, c := range s[1:] {
73 | if f := set.Lookup(string(c)); f == nil {
74 | return false
75 | }
76 | }
77 | return true
78 | }
79 |
80 | if !isSplittable(arg) || !shortFlagsExist(arg) {
81 | return []string{arg}
82 | }
83 |
84 | separated := make([]string, 0, len(arg)-1)
85 | for _, flagChar := range arg[1:] {
86 | separated = append(separated, "-"+string(flagChar))
87 | }
88 |
89 | return separated
90 | }
91 |
92 | func isSplittable(flagArg string) bool {
93 | return strings.HasPrefix(flagArg, "-") && !strings.HasPrefix(flagArg, "--") && len(flagArg) > 2
94 | }
95 |
--------------------------------------------------------------------------------
/vendor/github.com/urfave/cli/v2/flag_uint.go:
--------------------------------------------------------------------------------
1 | package cli
2 |
3 | import (
4 | "flag"
5 | "fmt"
6 | "strconv"
7 | )
8 |
9 | // UintFlag is a flag with type uint
10 | type UintFlag struct {
11 | Name string
12 | Aliases []string
13 | Usage string
14 | EnvVars []string
15 | FilePath string
16 | Required bool
17 | Hidden bool
18 | Value uint
19 | DefaultText string
20 | Destination *uint
21 | HasBeenSet bool
22 | }
23 |
24 | // IsSet returns whether or not the flag has been set through env or file
25 | func (f *UintFlag) IsSet() bool {
26 | return f.HasBeenSet
27 | }
28 |
29 | // String returns a readable representation of this value
30 | // (for usage defaults)
31 | func (f *UintFlag) String() string {
32 | return FlagStringer(f)
33 | }
34 |
35 | // Names returns the names of the flag
36 | func (f *UintFlag) Names() []string {
37 | return flagNames(f.Name, f.Aliases)
38 | }
39 |
40 | // IsRequired returns whether or not the flag is required
41 | func (f *UintFlag) IsRequired() bool {
42 | return f.Required
43 | }
44 |
45 | // TakesValue returns true of the flag takes a value, otherwise false
46 | func (f *UintFlag) TakesValue() bool {
47 | return true
48 | }
49 |
50 | // GetUsage returns the usage string for the flag
51 | func (f *UintFlag) GetUsage() string {
52 | return f.Usage
53 | }
54 |
55 | // Apply populates the flag given the flag set and environment
56 | func (f *UintFlag) Apply(set *flag.FlagSet) error {
57 | if val, ok := flagFromEnvOrFile(f.EnvVars, f.FilePath); ok {
58 | if val != "" {
59 | valInt, err := strconv.ParseUint(val, 0, 64)
60 | if err != nil {
61 | return fmt.Errorf("could not parse %q as uint value for flag %s: %s", val, f.Name, err)
62 | }
63 |
64 | f.Value = uint(valInt)
65 | f.HasBeenSet = true
66 | }
67 | }
68 |
69 | for _, name := range f.Names() {
70 | if f.Destination != nil {
71 | set.UintVar(f.Destination, name, f.Value, f.Usage)
72 | continue
73 | }
74 | set.Uint(name, f.Value, f.Usage)
75 | }
76 |
77 | return nil
78 | }
79 |
80 | // GetValue returns the flags value as string representation and an empty
81 | // string if the flag takes no value at all.
82 | func (f *UintFlag) GetValue() string {
83 | return fmt.Sprintf("%d", f.Value)
84 | }
85 |
86 | // Uint looks up the value of a local UintFlag, returns
87 | // 0 if not found
88 | func (c *Context) Uint(name string) uint {
89 | if fs := lookupFlagSet(name, c); fs != nil {
90 | return lookupUint(name, fs)
91 | }
92 | return 0
93 | }
94 |
95 | func lookupUint(name string, set *flag.FlagSet) uint {
96 | f := set.Lookup(name)
97 | if f != nil {
98 | parsed, err := strconv.ParseUint(f.Value.String(), 0, 64)
99 | if err != nil {
100 | return 0
101 | }
102 | return uint(parsed)
103 | }
104 | return 0
105 | }
106 |
--------------------------------------------------------------------------------
/vendor/github.com/urfave/cli/v2/flag_int64.go:
--------------------------------------------------------------------------------
1 | package cli
2 |
3 | import (
4 | "flag"
5 | "fmt"
6 | "strconv"
7 | )
8 |
9 | // Int64Flag is a flag with type int64
10 | type Int64Flag struct {
11 | Name string
12 | Aliases []string
13 | Usage string
14 | EnvVars []string
15 | FilePath string
16 | Required bool
17 | Hidden bool
18 | Value int64
19 | DefaultText string
20 | Destination *int64
21 | HasBeenSet bool
22 | }
23 |
24 | // IsSet returns whether or not the flag has been set through env or file
25 | func (f *Int64Flag) IsSet() bool {
26 | return f.HasBeenSet
27 | }
28 |
29 | // String returns a readable representation of this value
30 | // (for usage defaults)
31 | func (f *Int64Flag) String() string {
32 | return FlagStringer(f)
33 | }
34 |
35 | // Names returns the names of the flag
36 | func (f *Int64Flag) Names() []string {
37 | return flagNames(f.Name, f.Aliases)
38 | }
39 |
40 | // IsRequired returns whether or not the flag is required
41 | func (f *Int64Flag) IsRequired() bool {
42 | return f.Required
43 | }
44 |
45 | // TakesValue returns true of the flag takes a value, otherwise false
46 | func (f *Int64Flag) TakesValue() bool {
47 | return true
48 | }
49 |
50 | // GetUsage returns the usage string for the flag
51 | func (f *Int64Flag) GetUsage() string {
52 | return f.Usage
53 | }
54 |
55 | // GetValue returns the flags value as string representation and an empty
56 | // string if the flag takes no value at all.
57 | func (f *Int64Flag) GetValue() string {
58 | return fmt.Sprintf("%d", f.Value)
59 | }
60 |
61 | // Apply populates the flag given the flag set and environment
62 | func (f *Int64Flag) Apply(set *flag.FlagSet) error {
63 | if val, ok := flagFromEnvOrFile(f.EnvVars, f.FilePath); ok {
64 | if val != "" {
65 | valInt, err := strconv.ParseInt(val, 0, 64)
66 |
67 | if err != nil {
68 | return fmt.Errorf("could not parse %q as int value for flag %s: %s", val, f.Name, err)
69 | }
70 |
71 | f.Value = valInt
72 | f.HasBeenSet = true
73 | }
74 | }
75 |
76 | for _, name := range f.Names() {
77 | if f.Destination != nil {
78 | set.Int64Var(f.Destination, name, f.Value, f.Usage)
79 | continue
80 | }
81 | set.Int64(name, f.Value, f.Usage)
82 | }
83 | return nil
84 | }
85 |
86 | // Int64 looks up the value of a local Int64Flag, returns
87 | // 0 if not found
88 | func (c *Context) Int64(name string) int64 {
89 | if fs := lookupFlagSet(name, c); fs != nil {
90 | return lookupInt64(name, fs)
91 | }
92 | return 0
93 | }
94 |
95 | func lookupInt64(name string, set *flag.FlagSet) int64 {
96 | f := set.Lookup(name)
97 | if f != nil {
98 | parsed, err := strconv.ParseInt(f.Value.String(), 0, 64)
99 | if err != nil {
100 | return 0
101 | }
102 | return parsed
103 | }
104 | return 0
105 | }
106 |
--------------------------------------------------------------------------------
/vendor/github.com/urfave/cli/v2/flag_uint64.go:
--------------------------------------------------------------------------------
1 | package cli
2 |
3 | import (
4 | "flag"
5 | "fmt"
6 | "strconv"
7 | )
8 |
9 | // Uint64Flag is a flag with type uint64
10 | type Uint64Flag struct {
11 | Name string
12 | Aliases []string
13 | Usage string
14 | EnvVars []string
15 | FilePath string
16 | Required bool
17 | Hidden bool
18 | Value uint64
19 | DefaultText string
20 | Destination *uint64
21 | HasBeenSet bool
22 | }
23 |
24 | // IsSet returns whether or not the flag has been set through env or file
25 | func (f *Uint64Flag) IsSet() bool {
26 | return f.HasBeenSet
27 | }
28 |
29 | // String returns a readable representation of this value
30 | // (for usage defaults)
31 | func (f *Uint64Flag) String() string {
32 | return FlagStringer(f)
33 | }
34 |
35 | // Names returns the names of the flag
36 | func (f *Uint64Flag) Names() []string {
37 | return flagNames(f.Name, f.Aliases)
38 | }
39 |
40 | // IsRequired returns whether or not the flag is required
41 | func (f *Uint64Flag) IsRequired() bool {
42 | return f.Required
43 | }
44 |
45 | // TakesValue returns true of the flag takes a value, otherwise false
46 | func (f *Uint64Flag) TakesValue() bool {
47 | return true
48 | }
49 |
50 | // GetUsage returns the usage string for the flag
51 | func (f *Uint64Flag) GetUsage() string {
52 | return f.Usage
53 | }
54 |
55 | // Apply populates the flag given the flag set and environment
56 | func (f *Uint64Flag) Apply(set *flag.FlagSet) error {
57 | if val, ok := flagFromEnvOrFile(f.EnvVars, f.FilePath); ok {
58 | if val != "" {
59 | valInt, err := strconv.ParseUint(val, 0, 64)
60 | if err != nil {
61 | return fmt.Errorf("could not parse %q as uint64 value for flag %s: %s", val, f.Name, err)
62 | }
63 |
64 | f.Value = valInt
65 | f.HasBeenSet = true
66 | }
67 | }
68 |
69 | for _, name := range f.Names() {
70 | if f.Destination != nil {
71 | set.Uint64Var(f.Destination, name, f.Value, f.Usage)
72 | continue
73 | }
74 | set.Uint64(name, f.Value, f.Usage)
75 | }
76 |
77 | return nil
78 | }
79 |
80 | // GetValue returns the flags value as string representation and an empty
81 | // string if the flag takes no value at all.
82 | func (f *Uint64Flag) GetValue() string {
83 | return fmt.Sprintf("%d", f.Value)
84 | }
85 |
86 | // Uint64 looks up the value of a local Uint64Flag, returns
87 | // 0 if not found
88 | func (c *Context) Uint64(name string) uint64 {
89 | if fs := lookupFlagSet(name, c); fs != nil {
90 | return lookupUint64(name, fs)
91 | }
92 | return 0
93 | }
94 |
95 | func lookupUint64(name string, set *flag.FlagSet) uint64 {
96 | f := set.Lookup(name)
97 | if f != nil {
98 | parsed, err := strconv.ParseUint(f.Value.String(), 0, 64)
99 | if err != nil {
100 | return 0
101 | }
102 | return parsed
103 | }
104 | return 0
105 | }
106 |
--------------------------------------------------------------------------------
/.goreleaser.yml:
--------------------------------------------------------------------------------
1 | project_name: renderizer
2 | builds:
3 | -
4 | binary: renderizer
5 | main: ./cmd/renderizer/main.go
6 | goos:
7 | - windows
8 | - darwin
9 | - linux
10 | goarch:
11 | - amd64
12 | ldflags: '-s -w -X main.version={{.Version}} -X main.tag={{.Tag}} -X main.commitHash={{.FullCommit}} -X main.commitTime={{ index .Env "COMMIT_TIME" }} -X main.buildTime={{ time "20060102T150405" }}'
13 |
14 | dist: build/dist
15 |
16 | snapshot:
17 | name_template: '{{.Version}}.snapshot'
18 |
19 | release:
20 | github:
21 | owner: gomatic
22 | name: renderizer
23 |
24 | signs:
25 | -
26 | artifacts: all
27 | args: ["--batch", "-u", "{{ .Env.GPG_FINGERPRINT }}", "--output", "${signature}", "--detach-sign", "${artifact}"]
28 |
29 | checksum:
30 | name_template: '{{ .ProjectName }}_checksums.txt'
31 |
32 | changelog:
33 | sort: asc
34 | filters:
35 | exclude:
36 | - docs
37 | - Merge pull request
38 | - Merge branch
39 |
40 | archives:
41 | -
42 | name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
43 | replacements:
44 | 386: i386
45 | amd64: x86_64
46 | format_overrides:
47 | - goos: windows
48 | format: zip
49 |
50 | brews:
51 | -
52 | # Name template of the recipe
53 | # Default to project name
54 | name: renderizer
55 |
56 | # GOARM to specify which 32-bit arm version to use if there are multiple versions
57 | # from the build section. Brew formulas support atm only one 32-bit version.
58 | # Default is 6 for all artifacts or each id if there a multiple versions.
59 | goarm: 6
60 |
61 | # GitHub/GitLab repository to push the formula to
62 | tap:
63 | owner: gomatic
64 | name: homebrew-renderizer
65 | # Optionally a token can be provided, if it differs from the token provided to GoReleaser
66 | token: "{{ .Env.HOMEBREW_TAP_GITHUB_TOKEN }}"
67 |
68 | url_template: "https://github.com/gomatic/renderizer/releases/download/{{ .Tag }}/{{ .ArtifactName }}"
69 |
70 | # Git author used to commit to the repository.
71 | # Defaults are shown.
72 | commit_author:
73 | name: goreleaserbot
74 | email: nicerobot@users.noreply.github.com
75 |
76 | # Folder inside the repository to put the formula.
77 | # Default is the root folder.
78 | folder: Formula
79 |
80 | # Your app's homepage.
81 | # Default is empty.
82 | homepage: "https://github.com/gomatic/renderizer"
83 |
84 | # Your app's description.
85 | # Default is empty.
86 | description: "CLI to render Go template text files based on command line parameters and/or a YAML"
87 |
88 | # SPDX identifier of your app's license.
89 | # Default is empty.
90 | license: "GPL-3.0"
91 |
92 | # Custom install script for brew.
93 | # Default is 'bin.install "program"'.
94 | install: |
95 | bin.install "renderizer"
96 |
--------------------------------------------------------------------------------
/vendor/github.com/urfave/cli/v2/flag_float64.go:
--------------------------------------------------------------------------------
1 | package cli
2 |
3 | import (
4 | "flag"
5 | "fmt"
6 | "strconv"
7 | )
8 |
9 | // Float64Flag is a flag with type float64
10 | type Float64Flag struct {
11 | Name string
12 | Aliases []string
13 | Usage string
14 | EnvVars []string
15 | FilePath string
16 | Required bool
17 | Hidden bool
18 | Value float64
19 | DefaultText string
20 | Destination *float64
21 | HasBeenSet bool
22 | }
23 |
24 | // IsSet returns whether or not the flag has been set through env or file
25 | func (f *Float64Flag) IsSet() bool {
26 | return f.HasBeenSet
27 | }
28 |
29 | // String returns a readable representation of this value
30 | // (for usage defaults)
31 | func (f *Float64Flag) String() string {
32 | return FlagStringer(f)
33 | }
34 |
35 | // Names returns the names of the flag
36 | func (f *Float64Flag) Names() []string {
37 | return flagNames(f.Name, f.Aliases)
38 | }
39 |
40 | // IsRequired returns whether or not the flag is required
41 | func (f *Float64Flag) IsRequired() bool {
42 | return f.Required
43 | }
44 |
45 | // TakesValue returns true of the flag takes a value, otherwise false
46 | func (f *Float64Flag) TakesValue() bool {
47 | return true
48 | }
49 |
50 | // GetUsage returns the usage string for the flag
51 | func (f *Float64Flag) GetUsage() string {
52 | return f.Usage
53 | }
54 |
55 | // GetValue returns the flags value as string representation and an empty
56 | // string if the flag takes no value at all.
57 | func (f *Float64Flag) GetValue() string {
58 | return fmt.Sprintf("%f", f.Value)
59 | }
60 |
61 | // Apply populates the flag given the flag set and environment
62 | func (f *Float64Flag) Apply(set *flag.FlagSet) error {
63 | if val, ok := flagFromEnvOrFile(f.EnvVars, f.FilePath); ok {
64 | if val != "" {
65 | valFloat, err := strconv.ParseFloat(val, 10)
66 |
67 | if err != nil {
68 | return fmt.Errorf("could not parse %q as float64 value for flag %s: %s", val, f.Name, err)
69 | }
70 |
71 | f.Value = valFloat
72 | f.HasBeenSet = true
73 | }
74 | }
75 |
76 | for _, name := range f.Names() {
77 | if f.Destination != nil {
78 | set.Float64Var(f.Destination, name, f.Value, f.Usage)
79 | continue
80 | }
81 | set.Float64(name, f.Value, f.Usage)
82 | }
83 |
84 | return nil
85 | }
86 |
87 | // Float64 looks up the value of a local Float64Flag, returns
88 | // 0 if not found
89 | func (c *Context) Float64(name string) float64 {
90 | if fs := lookupFlagSet(name, c); fs != nil {
91 | return lookupFloat64(name, fs)
92 | }
93 | return 0
94 | }
95 |
96 | func lookupFloat64(name string, set *flag.FlagSet) float64 {
97 | f := set.Lookup(name)
98 | if f != nil {
99 | parsed, err := strconv.ParseFloat(f.Value.String(), 64)
100 | if err != nil {
101 | return 0
102 | }
103 | return parsed
104 | }
105 | return 0
106 | }
107 |
--------------------------------------------------------------------------------
/vendor/github.com/urfave/cli/v2/flag_generic.go:
--------------------------------------------------------------------------------
1 | package cli
2 |
3 | import (
4 | "flag"
5 | "fmt"
6 | )
7 |
8 | // Generic is a generic parseable type identified by a specific flag
9 | type Generic interface {
10 | Set(value string) error
11 | String() string
12 | }
13 |
14 | // GenericFlag is a flag with type Generic
15 | type GenericFlag struct {
16 | Name string
17 | Aliases []string
18 | Usage string
19 | EnvVars []string
20 | FilePath string
21 | Required bool
22 | Hidden bool
23 | TakesFile bool
24 | Value Generic
25 | DefaultText string
26 | HasBeenSet bool
27 | }
28 |
29 | // IsSet returns whether or not the flag has been set through env or file
30 | func (f *GenericFlag) IsSet() bool {
31 | return f.HasBeenSet
32 | }
33 |
34 | // String returns a readable representation of this value
35 | // (for usage defaults)
36 | func (f *GenericFlag) String() string {
37 | return FlagStringer(f)
38 | }
39 |
40 | // Names returns the names of the flag
41 | func (f *GenericFlag) Names() []string {
42 | return flagNames(f.Name, f.Aliases)
43 | }
44 |
45 | // IsRequired returns whether or not the flag is required
46 | func (f *GenericFlag) IsRequired() bool {
47 | return f.Required
48 | }
49 |
50 | // TakesValue returns true of the flag takes a value, otherwise false
51 | func (f *GenericFlag) TakesValue() bool {
52 | return true
53 | }
54 |
55 | // GetUsage returns the usage string for the flag
56 | func (f *GenericFlag) GetUsage() string {
57 | return f.Usage
58 | }
59 |
60 | // GetValue returns the flags value as string representation and an empty
61 | // string if the flag takes no value at all.
62 | func (f *GenericFlag) GetValue() string {
63 | if f.Value != nil {
64 | return f.Value.String()
65 | }
66 | return ""
67 | }
68 |
69 | // Apply takes the flagset and calls Set on the generic flag with the value
70 | // provided by the user for parsing by the flag
71 | func (f GenericFlag) Apply(set *flag.FlagSet) error {
72 | if val, ok := flagFromEnvOrFile(f.EnvVars, f.FilePath); ok {
73 | if val != "" {
74 | if err := f.Value.Set(val); err != nil {
75 | return fmt.Errorf("could not parse %q as value for flag %s: %s", val, f.Name, err)
76 | }
77 |
78 | f.HasBeenSet = true
79 | }
80 | }
81 |
82 | for _, name := range f.Names() {
83 | set.Var(f.Value, name, f.Usage)
84 | }
85 |
86 | return nil
87 | }
88 |
89 | // Generic looks up the value of a local GenericFlag, returns
90 | // nil if not found
91 | func (c *Context) Generic(name string) interface{} {
92 | if fs := lookupFlagSet(name, c); fs != nil {
93 | return lookupGeneric(name, fs)
94 | }
95 | return nil
96 | }
97 |
98 | func lookupGeneric(name string, set *flag.FlagSet) interface{} {
99 | f := set.Lookup(name)
100 | if f != nil {
101 | parsed, err := f.Value, error(nil)
102 | if err != nil {
103 | return nil
104 | }
105 | return parsed
106 | }
107 | return nil
108 | }
109 |
--------------------------------------------------------------------------------
/vendor/github.com/urfave/cli/v2/flag_duration.go:
--------------------------------------------------------------------------------
1 | package cli
2 |
3 | import (
4 | "flag"
5 | "fmt"
6 | "time"
7 | )
8 |
9 | // DurationFlag is a flag with type time.Duration (see https://golang.org/pkg/time/#ParseDuration)
10 | type DurationFlag struct {
11 | Name string
12 | Aliases []string
13 | Usage string
14 | EnvVars []string
15 | FilePath string
16 | Required bool
17 | Hidden bool
18 | Value time.Duration
19 | DefaultText string
20 | Destination *time.Duration
21 | HasBeenSet bool
22 | }
23 |
24 | // IsSet returns whether or not the flag has been set through env or file
25 | func (f *DurationFlag) IsSet() bool {
26 | return f.HasBeenSet
27 | }
28 |
29 | // String returns a readable representation of this value
30 | // (for usage defaults)
31 | func (f *DurationFlag) String() string {
32 | return FlagStringer(f)
33 | }
34 |
35 | // Names returns the names of the flag
36 | func (f *DurationFlag) Names() []string {
37 | return flagNames(f.Name, f.Aliases)
38 | }
39 |
40 | // IsRequired returns whether or not the flag is required
41 | func (f *DurationFlag) IsRequired() bool {
42 | return f.Required
43 | }
44 |
45 | // TakesValue returns true of the flag takes a value, otherwise false
46 | func (f *DurationFlag) TakesValue() bool {
47 | return true
48 | }
49 |
50 | // GetUsage returns the usage string for the flag
51 | func (f *DurationFlag) GetUsage() string {
52 | return f.Usage
53 | }
54 |
55 | // GetValue returns the flags value as string representation and an empty
56 | // string if the flag takes no value at all.
57 | func (f *DurationFlag) GetValue() string {
58 | return f.Value.String()
59 | }
60 |
61 | // Apply populates the flag given the flag set and environment
62 | func (f *DurationFlag) Apply(set *flag.FlagSet) error {
63 | if val, ok := flagFromEnvOrFile(f.EnvVars, f.FilePath); ok {
64 | if val != "" {
65 | valDuration, err := time.ParseDuration(val)
66 |
67 | if err != nil {
68 | return fmt.Errorf("could not parse %q as duration value for flag %s: %s", val, f.Name, err)
69 | }
70 |
71 | f.Value = valDuration
72 | f.HasBeenSet = true
73 | }
74 | }
75 |
76 | for _, name := range f.Names() {
77 | if f.Destination != nil {
78 | set.DurationVar(f.Destination, name, f.Value, f.Usage)
79 | continue
80 | }
81 | set.Duration(name, f.Value, f.Usage)
82 | }
83 | return nil
84 | }
85 |
86 | // Duration looks up the value of a local DurationFlag, returns
87 | // 0 if not found
88 | func (c *Context) Duration(name string) time.Duration {
89 | if fs := lookupFlagSet(name, c); fs != nil {
90 | return lookupDuration(name, fs)
91 | }
92 | return 0
93 | }
94 |
95 | func lookupDuration(name string, set *flag.FlagSet) time.Duration {
96 | f := set.Lookup(name)
97 | if f != nil {
98 | parsed, err := time.ParseDuration(f.Value.String())
99 | if err != nil {
100 | return 0
101 | }
102 | return parsed
103 | }
104 | return 0
105 | }
106 |
--------------------------------------------------------------------------------
/vendor/gopkg.in/yaml.v2/sorter.go:
--------------------------------------------------------------------------------
1 | package yaml
2 |
3 | import (
4 | "reflect"
5 | "unicode"
6 | )
7 |
8 | type keyList []reflect.Value
9 |
10 | func (l keyList) Len() int { return len(l) }
11 | func (l keyList) Swap(i, j int) { l[i], l[j] = l[j], l[i] }
12 | func (l keyList) Less(i, j int) bool {
13 | a := l[i]
14 | b := l[j]
15 | ak := a.Kind()
16 | bk := b.Kind()
17 | for (ak == reflect.Interface || ak == reflect.Ptr) && !a.IsNil() {
18 | a = a.Elem()
19 | ak = a.Kind()
20 | }
21 | for (bk == reflect.Interface || bk == reflect.Ptr) && !b.IsNil() {
22 | b = b.Elem()
23 | bk = b.Kind()
24 | }
25 | af, aok := keyFloat(a)
26 | bf, bok := keyFloat(b)
27 | if aok && bok {
28 | if af != bf {
29 | return af < bf
30 | }
31 | if ak != bk {
32 | return ak < bk
33 | }
34 | return numLess(a, b)
35 | }
36 | if ak != reflect.String || bk != reflect.String {
37 | return ak < bk
38 | }
39 | ar, br := []rune(a.String()), []rune(b.String())
40 | for i := 0; i < len(ar) && i < len(br); i++ {
41 | if ar[i] == br[i] {
42 | continue
43 | }
44 | al := unicode.IsLetter(ar[i])
45 | bl := unicode.IsLetter(br[i])
46 | if al && bl {
47 | return ar[i] < br[i]
48 | }
49 | if al || bl {
50 | return bl
51 | }
52 | var ai, bi int
53 | var an, bn int64
54 | if ar[i] == '0' || br[i] == '0' {
55 | for j := i-1; j >= 0 && unicode.IsDigit(ar[j]); j-- {
56 | if ar[j] != '0' {
57 | an = 1
58 | bn = 1
59 | break
60 | }
61 | }
62 | }
63 | for ai = i; ai < len(ar) && unicode.IsDigit(ar[ai]); ai++ {
64 | an = an*10 + int64(ar[ai]-'0')
65 | }
66 | for bi = i; bi < len(br) && unicode.IsDigit(br[bi]); bi++ {
67 | bn = bn*10 + int64(br[bi]-'0')
68 | }
69 | if an != bn {
70 | return an < bn
71 | }
72 | if ai != bi {
73 | return ai < bi
74 | }
75 | return ar[i] < br[i]
76 | }
77 | return len(ar) < len(br)
78 | }
79 |
80 | // keyFloat returns a float value for v if it is a number/bool
81 | // and whether it is a number/bool or not.
82 | func keyFloat(v reflect.Value) (f float64, ok bool) {
83 | switch v.Kind() {
84 | case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
85 | return float64(v.Int()), true
86 | case reflect.Float32, reflect.Float64:
87 | return v.Float(), true
88 | case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
89 | return float64(v.Uint()), true
90 | case reflect.Bool:
91 | if v.Bool() {
92 | return 1, true
93 | }
94 | return 0, true
95 | }
96 | return 0, false
97 | }
98 |
99 | // numLess returns whether a < b.
100 | // a and b must necessarily have the same kind.
101 | func numLess(a, b reflect.Value) bool {
102 | switch a.Kind() {
103 | case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
104 | return a.Int() < b.Int()
105 | case reflect.Float32, reflect.Float64:
106 | return a.Float() < b.Float()
107 | case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
108 | return a.Uint() < b.Uint()
109 | case reflect.Bool:
110 | return !a.Bool() && b.Bool()
111 | }
112 | panic("not a number")
113 | }
114 |
--------------------------------------------------------------------------------
/vendor/github.com/imdario/mergo/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6 |
7 | ## Our Standards
8 |
9 | Examples of behavior that contributes to creating a positive environment include:
10 |
11 | * Using welcoming and inclusive language
12 | * Being respectful of differing viewpoints and experiences
13 | * Gracefully accepting constructive criticism
14 | * Focusing on what is best for the community
15 | * Showing empathy towards other community members
16 |
17 | Examples of unacceptable behavior by participants include:
18 |
19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances
20 | * Trolling, insulting/derogatory comments, and personal or political attacks
21 | * Public or private harassment
22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission
23 | * Other conduct which could reasonably be considered inappropriate in a professional setting
24 |
25 | ## Our Responsibilities
26 |
27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28 |
29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30 |
31 | ## Scope
32 |
33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34 |
35 | ## Enforcement
36 |
37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at i@dario.im. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38 |
39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40 |
41 | ## Attribution
42 |
43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44 |
45 | [homepage]: http://contributor-covenant.org
46 | [version]: http://contributor-covenant.org/version/1/4/
47 |
--------------------------------------------------------------------------------
/vendor/gopkg.in/yaml.v2/README.md:
--------------------------------------------------------------------------------
1 | # YAML support for the Go language
2 |
3 | Introduction
4 | ------------
5 |
6 | The yaml package enables Go programs to comfortably encode and decode YAML
7 | values. It was developed within [Canonical](https://www.canonical.com) as
8 | part of the [juju](https://juju.ubuntu.com) project, and is based on a
9 | pure Go port of the well-known [libyaml](http://pyyaml.org/wiki/LibYAML)
10 | C library to parse and generate YAML data quickly and reliably.
11 |
12 | Compatibility
13 | -------------
14 |
15 | The yaml package supports most of YAML 1.1 and 1.2, including support for
16 | anchors, tags, map merging, etc. Multi-document unmarshalling is not yet
17 | implemented, and base-60 floats from YAML 1.1 are purposefully not
18 | supported since they're a poor design and are gone in YAML 1.2.
19 |
20 | Installation and usage
21 | ----------------------
22 |
23 | The import path for the package is *gopkg.in/yaml.v2*.
24 |
25 | To install it, run:
26 |
27 | go get gopkg.in/yaml.v2
28 |
29 | API documentation
30 | -----------------
31 |
32 | If opened in a browser, the import path itself leads to the API documentation:
33 |
34 | * [https://gopkg.in/yaml.v2](https://gopkg.in/yaml.v2)
35 |
36 | API stability
37 | -------------
38 |
39 | The package API for yaml v2 will remain stable as described in [gopkg.in](https://gopkg.in).
40 |
41 |
42 | License
43 | -------
44 |
45 | The yaml package is licensed under the Apache License 2.0. Please see the LICENSE file for details.
46 |
47 |
48 | Example
49 | -------
50 |
51 | ```Go
52 | package main
53 |
54 | import (
55 | "fmt"
56 | "log"
57 |
58 | "gopkg.in/yaml.v2"
59 | )
60 |
61 | var data = `
62 | a: Easy!
63 | b:
64 | c: 2
65 | d: [3, 4]
66 | `
67 |
68 | // Note: struct fields must be public in order for unmarshal to
69 | // correctly populate the data.
70 | type T struct {
71 | A string
72 | B struct {
73 | RenamedC int `yaml:"c"`
74 | D []int `yaml:",flow"`
75 | }
76 | }
77 |
78 | func main() {
79 | t := T{}
80 |
81 | err := yaml.Unmarshal([]byte(data), &t)
82 | if err != nil {
83 | log.Fatalf("error: %v", err)
84 | }
85 | fmt.Printf("--- t:\n%v\n\n", t)
86 |
87 | d, err := yaml.Marshal(&t)
88 | if err != nil {
89 | log.Fatalf("error: %v", err)
90 | }
91 | fmt.Printf("--- t dump:\n%s\n\n", string(d))
92 |
93 | m := make(map[interface{}]interface{})
94 |
95 | err = yaml.Unmarshal([]byte(data), &m)
96 | if err != nil {
97 | log.Fatalf("error: %v", err)
98 | }
99 | fmt.Printf("--- m:\n%v\n\n", m)
100 |
101 | d, err = yaml.Marshal(&m)
102 | if err != nil {
103 | log.Fatalf("error: %v", err)
104 | }
105 | fmt.Printf("--- m dump:\n%s\n\n", string(d))
106 | }
107 | ```
108 |
109 | This example will generate the following output:
110 |
111 | ```
112 | --- t:
113 | {Easy! {2 [3 4]}}
114 |
115 | --- t dump:
116 | a: Easy!
117 | b:
118 | c: 2
119 | d: [3, 4]
120 |
121 |
122 | --- m:
123 | map[a:Easy! b:map[c:2 d:[3 4]]]
124 |
125 | --- m dump:
126 | a: Easy!
127 | b:
128 | c: 2
129 | d:
130 | - 3
131 | - 4
132 | ```
133 |
134 |
--------------------------------------------------------------------------------
/vendor/github.com/urfave/cli/v2/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as
6 | contributors and maintainers pledge to making participation in our project and
7 | our community a harassment-free experience for everyone, regardless of age, body
8 | size, disability, ethnicity, gender identity and expression, level of experience,
9 | education, socio-economic status, nationality, personal appearance, race,
10 | religion, or sexual identity and orientation.
11 |
12 | ## Our Standards
13 |
14 | Examples of behavior that contributes to creating a positive environment
15 | include:
16 |
17 | * Using welcoming and inclusive language
18 | * Being respectful of differing viewpoints and experiences
19 | * Gracefully accepting constructive criticism
20 | * Focusing on what is best for the community
21 | * Showing empathy towards other community members
22 |
23 | Examples of unacceptable behavior by participants include:
24 |
25 | * The use of sexualized language or imagery and unwelcome sexual attention or
26 | advances
27 | * Trolling, insulting/derogatory comments, and personal or political attacks
28 | * Public or private harassment
29 | * Publishing others' private information, such as a physical or electronic
30 | address, without explicit permission
31 | * Other conduct which could reasonably be considered inappropriate in a
32 | professional setting
33 |
34 | ## Our Responsibilities
35 |
36 | Project maintainers are responsible for clarifying the standards of acceptable
37 | behavior and are expected to take appropriate and fair corrective action in
38 | response to any instances of unacceptable behavior.
39 |
40 | Project maintainers have the right and responsibility to remove, edit, or
41 | reject comments, commits, code, wiki edits, issues, and other contributions
42 | that are not aligned to this Code of Conduct, or to ban temporarily or
43 | permanently any contributor for other behaviors that they deem inappropriate,
44 | threatening, offensive, or harmful.
45 |
46 | ## Scope
47 |
48 | This Code of Conduct applies both within project spaces and in public spaces
49 | when an individual is representing the project or its community. Examples of
50 | representing a project or community include using an official project e-mail
51 | address, posting via an official social media account, or acting as an appointed
52 | representative at an online or offline event. Representation of a project may be
53 | further defined and clarified by project maintainers.
54 |
55 | ## Enforcement
56 |
57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
58 | reported by contacting Dan Buch at dan@meatballhat.com. All complaints will be
59 | reviewed and investigated and will result in a response that is deemed necessary
60 | and appropriate to the circumstances. The project team is obligated to maintain
61 | confidentiality with regard to the reporter of an incident. Further details of
62 | specific enforcement policies may be posted separately.
63 |
64 | Project maintainers who do not follow or enforce the Code of Conduct in good
65 | faith may face temporary or permanent repercussions as determined by other
66 | members of the project's leadership.
67 |
68 | ## Attribution
69 |
70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72 |
73 | [homepage]: https://www.contributor-covenant.org
74 |
75 |
--------------------------------------------------------------------------------
/pkg/renderizer/renderizer_test.go:
--------------------------------------------------------------------------------
1 | package renderizer
2 |
3 | import (
4 | "reflect"
5 | "testing"
6 | )
7 |
8 | func TestNew(t *testing.T) {
9 | type args struct {
10 | settings Options
11 | }
12 | tests := []struct {
13 | name string
14 | args args
15 | want Renderizer
16 | }{
17 | // TODO: Add test cases.
18 | }
19 | for _, tt := range tests {
20 | t.Run(tt.name, func(t *testing.T) {
21 | if got := New(tt.args.settings); !reflect.DeepEqual(got, tt.want) {
22 | t.Errorf("New() = %v, want %v", got, tt.want)
23 | }
24 | })
25 | }
26 | }
27 |
28 | func TestRender(t *testing.T) {
29 | type args struct {
30 | settings Options
31 | }
32 | tests := []struct {
33 | name string
34 | args args
35 | wantErr bool
36 | }{
37 | // TODO: Add test cases.
38 | }
39 | for _, tt := range tests {
40 | t.Run(tt.name, func(t *testing.T) {
41 | if err := Render(tt.args.settings); (err != nil) != tt.wantErr {
42 | t.Errorf("Render() error = %v, wantErr %v", err, tt.wantErr)
43 | }
44 | })
45 | }
46 | }
47 |
48 | func TestOptions_Render(t *testing.T) {
49 | tests := []struct {
50 | name string
51 | settings *Options
52 | wantErr bool
53 | }{
54 | // TODO: Add test cases.
55 | }
56 | for _, tt := range tests {
57 | t.Run(tt.name, func(t *testing.T) {
58 | if err := tt.settings.Render(); (err != nil) != tt.wantErr {
59 | t.Errorf("Options.Render() error = %v, wantErr %v", err, tt.wantErr)
60 | }
61 | })
62 | }
63 | }
64 |
65 | func TestOptions_typer(t *testing.T) {
66 | type args struct {
67 | d string
68 | }
69 | tests := []struct {
70 | name string
71 | settings Options
72 | args args
73 | wantResult interface{}
74 | }{
75 | // TODO: Add test cases.
76 | }
77 | for _, tt := range tests {
78 | t.Run(tt.name, func(t *testing.T) {
79 | if gotResult := tt.settings.typer(tt.args.d); !reflect.DeepEqual(gotResult, tt.wantResult) {
80 | t.Errorf("Options.typer() = %v, want %v", gotResult, tt.wantResult)
81 | }
82 | })
83 | }
84 | }
85 |
86 | func Test_retypeSingleElementSlice(t *testing.T) {
87 | type args struct {
88 | config *retyperConfig
89 | }
90 | tests := []struct {
91 | name string
92 | args args
93 | }{
94 | // TODO: Add test cases.
95 | }
96 | for _, tt := range tests {
97 | t.Run(tt.name, func(t *testing.T) {
98 | retypeSingleElementSlice(tt.args.config)
99 | })
100 | }
101 | }
102 |
103 | func TestOptions_retyping(t *testing.T) {
104 | type args struct {
105 | source map[string]interface{}
106 | config retyperConfig
107 | }
108 | tests := []struct {
109 | name string
110 | settings Options
111 | args args
112 | want map[string]interface{}
113 | }{
114 | // TODO: Add test cases.
115 | }
116 | for _, tt := range tests {
117 | t.Run(tt.name, func(t *testing.T) {
118 | if got := tt.settings.retyping(tt.args.source, tt.args.config); !reflect.DeepEqual(got, tt.want) {
119 | t.Errorf("Options.retyping() = %v, want %v", got, tt.want)
120 | }
121 | })
122 | }
123 | }
124 |
125 | func TestOptions_Retyper(t *testing.T) {
126 | type args struct {
127 | source map[string]interface{}
128 | options []retyperOptions
129 | }
130 | tests := []struct {
131 | name string
132 | settings Options
133 | args args
134 | want map[string]interface{}
135 | }{
136 | // TODO: Add test cases.
137 | }
138 | for _, tt := range tests {
139 | t.Run(tt.name, func(t *testing.T) {
140 | if got := tt.settings.Retyper(tt.args.source, tt.args.options...); !reflect.DeepEqual(got, tt.want) {
141 | t.Errorf("Options.Retyper() = %v, want %v", got, tt.want)
142 | }
143 | })
144 | }
145 | }
146 |
--------------------------------------------------------------------------------
/go.sum:
--------------------------------------------------------------------------------
1 | github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
2 | github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
3 | github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
4 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
5 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
6 | github.com/gomatic/clock v0.0.0-20180923211445-dd56a80856b5/go.mod h1:qMIph1YAd255ac/BLtSwSfcWGQ69BdNuZ/EgkeuQakA=
7 | github.com/gomatic/clock v1.0.0 h1:xzAfBShN+Ko1S6pYt+HQZv79PcPVkIYG2c2eE4GkW6o=
8 | github.com/gomatic/clock v1.0.0/go.mod h1:CUAmVUNJnbL+LW+CZ0ei6OV+2reFSe9K70932UX/s3o=
9 | github.com/gomatic/funcmap v1.0.1 h1:Mu4vBNhJqhdh1klll9sKi0dfKve8G5zfRnPZ6pEmYVs=
10 | github.com/gomatic/funcmap v1.0.1/go.mod h1:z7ybRvcEKZsnKFnryQbI+5rgrD24Wj/QrDMhtkPwNIo=
11 | github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU=
12 | github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
13 | github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 h1:iQTw/8FWTuc7uiaSepXwyf3o52HaUYcV+Tu66S3F5GA=
14 | github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8=
15 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
16 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
17 | github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
18 | github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
19 | github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
20 | github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
21 | github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
22 | github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
23 | github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
24 | github.com/urfave/cli/v2 v2.3.0 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M=
25 | github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
26 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
27 | golang.org/x/crypto v0.0.0-20200429183012-4b2356b1ed79/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
28 | golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
29 | golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
30 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
31 | golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
32 | golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
33 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
34 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
35 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
36 | gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
37 | gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
38 | gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
39 | gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
40 |
--------------------------------------------------------------------------------
/vendor/github.com/kardianos/osext/osext_sysctl.go:
--------------------------------------------------------------------------------
1 | // Copyright 2012 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !go1.8,darwin !go1.8,freebsd openbsd
6 |
7 | package osext
8 |
9 | import (
10 | "os"
11 | "os/exec"
12 | "path/filepath"
13 | "runtime"
14 | "syscall"
15 | "unsafe"
16 | )
17 |
18 | var initCwd, initCwdErr = os.Getwd()
19 |
20 | func executable() (string, error) {
21 | var mib [4]int32
22 | switch runtime.GOOS {
23 | case "freebsd":
24 | mib = [4]int32{1 /* CTL_KERN */, 14 /* KERN_PROC */, 12 /* KERN_PROC_PATHNAME */, -1}
25 | case "darwin":
26 | mib = [4]int32{1 /* CTL_KERN */, 38 /* KERN_PROCARGS */, int32(os.Getpid()), -1}
27 | case "openbsd":
28 | mib = [4]int32{1 /* CTL_KERN */, 55 /* KERN_PROC_ARGS */, int32(os.Getpid()), 1 /* KERN_PROC_ARGV */}
29 | }
30 |
31 | n := uintptr(0)
32 | // Get length.
33 | _, _, errNum := syscall.Syscall6(syscall.SYS___SYSCTL, uintptr(unsafe.Pointer(&mib[0])), 4, 0, uintptr(unsafe.Pointer(&n)), 0, 0)
34 | if errNum != 0 {
35 | return "", errNum
36 | }
37 | if n == 0 { // This shouldn't happen.
38 | return "", nil
39 | }
40 | buf := make([]byte, n)
41 | _, _, errNum = syscall.Syscall6(syscall.SYS___SYSCTL, uintptr(unsafe.Pointer(&mib[0])), 4, uintptr(unsafe.Pointer(&buf[0])), uintptr(unsafe.Pointer(&n)), 0, 0)
42 | if errNum != 0 {
43 | return "", errNum
44 | }
45 | if n == 0 { // This shouldn't happen.
46 | return "", nil
47 | }
48 |
49 | var execPath string
50 | switch runtime.GOOS {
51 | case "openbsd":
52 | // buf now contains **argv, with pointers to each of the C-style
53 | // NULL terminated arguments.
54 | var args []string
55 | argv := uintptr(unsafe.Pointer(&buf[0]))
56 | Loop:
57 | for {
58 | argp := *(**[1 << 20]byte)(unsafe.Pointer(argv))
59 | if argp == nil {
60 | break
61 | }
62 | for i := 0; uintptr(i) < n; i++ {
63 | // we don't want the full arguments list
64 | if string(argp[i]) == " " {
65 | break Loop
66 | }
67 | if argp[i] != 0 {
68 | continue
69 | }
70 | args = append(args, string(argp[:i]))
71 | n -= uintptr(i)
72 | break
73 | }
74 | if n < unsafe.Sizeof(argv) {
75 | break
76 | }
77 | argv += unsafe.Sizeof(argv)
78 | n -= unsafe.Sizeof(argv)
79 | }
80 | execPath = args[0]
81 | // There is no canonical way to get an executable path on
82 | // OpenBSD, so check PATH in case we are called directly
83 | if execPath[0] != '/' && execPath[0] != '.' {
84 | execIsInPath, err := exec.LookPath(execPath)
85 | if err == nil {
86 | execPath = execIsInPath
87 | }
88 | }
89 | default:
90 | for i, v := range buf {
91 | if v == 0 {
92 | buf = buf[:i]
93 | break
94 | }
95 | }
96 | execPath = string(buf)
97 | }
98 |
99 | var err error
100 | // execPath will not be empty due to above checks.
101 | // Try to get the absolute path if the execPath is not rooted.
102 | if execPath[0] != '/' {
103 | execPath, err = getAbs(execPath)
104 | if err != nil {
105 | return execPath, err
106 | }
107 | }
108 | // For darwin KERN_PROCARGS may return the path to a symlink rather than the
109 | // actual executable.
110 | if runtime.GOOS == "darwin" {
111 | if execPath, err = filepath.EvalSymlinks(execPath); err != nil {
112 | return execPath, err
113 | }
114 | }
115 | return execPath, nil
116 | }
117 |
118 | func getAbs(execPath string) (string, error) {
119 | if initCwdErr != nil {
120 | return execPath, initCwdErr
121 | }
122 | // The execPath may begin with a "../" or a "./" so clean it first.
123 | // Join the two paths, trailing and starting slashes undetermined, so use
124 | // the generic Join function.
125 | return filepath.Join(initCwd, filepath.Clean(execPath)), nil
126 | }
127 |
--------------------------------------------------------------------------------
/vendor/github.com/urfave/cli/v2/docs.go:
--------------------------------------------------------------------------------
1 | package cli
2 |
3 | import (
4 | "bytes"
5 | "fmt"
6 | "io"
7 | "sort"
8 | "strings"
9 | "text/template"
10 |
11 | "github.com/cpuguy83/go-md2man/v2/md2man"
12 | )
13 |
14 | // ToMarkdown creates a markdown string for the `*App`
15 | // The function errors if either parsing or writing of the string fails.
16 | func (a *App) ToMarkdown() (string, error) {
17 | var w bytes.Buffer
18 | if err := a.writeDocTemplate(&w); err != nil {
19 | return "", err
20 | }
21 | return w.String(), nil
22 | }
23 |
24 | // ToMan creates a man page string for the `*App`
25 | // The function errors if either parsing or writing of the string fails.
26 | func (a *App) ToMan() (string, error) {
27 | var w bytes.Buffer
28 | if err := a.writeDocTemplate(&w); err != nil {
29 | return "", err
30 | }
31 | man := md2man.Render(w.Bytes())
32 | return string(man), nil
33 | }
34 |
35 | type cliTemplate struct {
36 | App *App
37 | Commands []string
38 | GlobalArgs []string
39 | SynopsisArgs []string
40 | }
41 |
42 | func (a *App) writeDocTemplate(w io.Writer) error {
43 | const name = "cli"
44 | t, err := template.New(name).Parse(MarkdownDocTemplate)
45 | if err != nil {
46 | return err
47 | }
48 | return t.ExecuteTemplate(w, name, &cliTemplate{
49 | App: a,
50 | Commands: prepareCommands(a.Commands, 0),
51 | GlobalArgs: prepareArgsWithValues(a.VisibleFlags()),
52 | SynopsisArgs: prepareArgsSynopsis(a.VisibleFlags()),
53 | })
54 | }
55 |
56 | func prepareCommands(commands []*Command, level int) []string {
57 | var coms []string
58 | for _, command := range commands {
59 | if command.Hidden {
60 | continue
61 | }
62 | usage := ""
63 | if command.Usage != "" {
64 | usage = command.Usage
65 | }
66 |
67 | prepared := fmt.Sprintf("%s %s\n\n%s\n",
68 | strings.Repeat("#", level+2),
69 | strings.Join(command.Names(), ", "),
70 | usage,
71 | )
72 |
73 | flags := prepareArgsWithValues(command.Flags)
74 | if len(flags) > 0 {
75 | prepared += fmt.Sprintf("\n%s", strings.Join(flags, "\n"))
76 | }
77 |
78 | coms = append(coms, prepared)
79 |
80 | // recursevly iterate subcommands
81 | if len(command.Subcommands) > 0 {
82 | coms = append(
83 | coms,
84 | prepareCommands(command.Subcommands, level+1)...,
85 | )
86 | }
87 | }
88 |
89 | return coms
90 | }
91 |
92 | func prepareArgsWithValues(flags []Flag) []string {
93 | return prepareFlags(flags, ", ", "**", "**", `""`, true)
94 | }
95 |
96 | func prepareArgsSynopsis(flags []Flag) []string {
97 | return prepareFlags(flags, "|", "[", "]", "[value]", false)
98 | }
99 |
100 | func prepareFlags(
101 | flags []Flag,
102 | sep, opener, closer, value string,
103 | addDetails bool,
104 | ) []string {
105 | args := []string{}
106 | for _, f := range flags {
107 | flag, ok := f.(DocGenerationFlag)
108 | if !ok {
109 | continue
110 | }
111 | modifiedArg := opener
112 |
113 | for _, s := range flag.Names() {
114 | trimmed := strings.TrimSpace(s)
115 | if len(modifiedArg) > len(opener) {
116 | modifiedArg += sep
117 | }
118 | if len(trimmed) > 1 {
119 | modifiedArg += fmt.Sprintf("--%s", trimmed)
120 | } else {
121 | modifiedArg += fmt.Sprintf("-%s", trimmed)
122 | }
123 | }
124 | modifiedArg += closer
125 | if flag.TakesValue() {
126 | modifiedArg += fmt.Sprintf("=%s", value)
127 | }
128 |
129 | if addDetails {
130 | modifiedArg += flagDetails(flag)
131 | }
132 |
133 | args = append(args, modifiedArg+"\n")
134 |
135 | }
136 | sort.Strings(args)
137 | return args
138 | }
139 |
140 | // flagDetails returns a string containing the flags metadata
141 | func flagDetails(flag DocGenerationFlag) string {
142 | description := flag.GetUsage()
143 | value := flag.GetValue()
144 | if value != "" {
145 | description += " (default: " + value + ")"
146 | }
147 | return ": " + description
148 | }
149 |
--------------------------------------------------------------------------------
/vendor/github.com/urfave/cli/v2/errors.go:
--------------------------------------------------------------------------------
1 | package cli
2 |
3 | import (
4 | "fmt"
5 | "io"
6 | "os"
7 | "strings"
8 | )
9 |
10 | // OsExiter is the function used when the app exits. If not set defaults to os.Exit.
11 | var OsExiter = os.Exit
12 |
13 | // ErrWriter is used to write errors to the user. This can be anything
14 | // implementing the io.Writer interface and defaults to os.Stderr.
15 | var ErrWriter io.Writer = os.Stderr
16 |
17 | // MultiError is an error that wraps multiple errors.
18 | type MultiError interface {
19 | error
20 | Errors() []error
21 | }
22 |
23 | // newMultiError creates a new MultiError. Pass in one or more errors.
24 | func newMultiError(err ...error) MultiError {
25 | ret := multiError(err)
26 | return &ret
27 | }
28 |
29 | type multiError []error
30 |
31 | // Error implements the error interface.
32 | func (m *multiError) Error() string {
33 | errs := make([]string, len(*m))
34 | for i, err := range *m {
35 | errs[i] = err.Error()
36 | }
37 |
38 | return strings.Join(errs, "\n")
39 | }
40 |
41 | // Errors returns a copy of the errors slice
42 | func (m *multiError) Errors() []error {
43 | errs := make([]error, len(*m))
44 | for _, err := range *m {
45 | errs = append(errs, err)
46 | }
47 | return errs
48 | }
49 |
50 | // ErrorFormatter is the interface that will suitably format the error output
51 | type ErrorFormatter interface {
52 | Format(s fmt.State, verb rune)
53 | }
54 |
55 | // ExitCoder is the interface checked by `App` and `Command` for a custom exit
56 | // code
57 | type ExitCoder interface {
58 | error
59 | ExitCode() int
60 | }
61 |
62 | type exitError struct {
63 | exitCode int
64 | message interface{}
65 | }
66 |
67 | // NewExitError calls Exit to create a new ExitCoder.
68 | //
69 | // Deprecated: This function is a duplicate of Exit and will eventually be removed.
70 | func NewExitError(message interface{}, exitCode int) ExitCoder {
71 | return Exit(message, exitCode)
72 | }
73 |
74 | // Exit wraps a message and exit code into an error, which by default is
75 | // handled with a call to os.Exit during default error handling.
76 | //
77 | // This is the simplest way to trigger a non-zero exit code for an App without
78 | // having to call os.Exit manually. During testing, this behavior can be avoided
79 | // by overiding the ExitErrHandler function on an App or the package-global
80 | // OsExiter function.
81 | func Exit(message interface{}, exitCode int) ExitCoder {
82 | return &exitError{
83 | message: message,
84 | exitCode: exitCode,
85 | }
86 | }
87 |
88 | func (ee *exitError) Error() string {
89 | return fmt.Sprintf("%v", ee.message)
90 | }
91 |
92 | func (ee *exitError) ExitCode() int {
93 | return ee.exitCode
94 | }
95 |
96 | // HandleExitCoder handles errors implementing ExitCoder by printing their
97 | // message and calling OsExiter with the given exit code.
98 | //
99 | // If the given error instead implements MultiError, each error will be checked
100 | // for the ExitCoder interface, and OsExiter will be called with the last exit
101 | // code found, or exit code 1 if no ExitCoder is found.
102 | //
103 | // This function is the default error-handling behavior for an App.
104 | func HandleExitCoder(err error) {
105 | if err == nil {
106 | return
107 | }
108 |
109 | if exitErr, ok := err.(ExitCoder); ok {
110 | if err.Error() != "" {
111 | if _, ok := exitErr.(ErrorFormatter); ok {
112 | _, _ = fmt.Fprintf(ErrWriter, "%+v\n", err)
113 | } else {
114 | _, _ = fmt.Fprintln(ErrWriter, err)
115 | }
116 | }
117 | OsExiter(exitErr.ExitCode())
118 | return
119 | }
120 |
121 | if multiErr, ok := err.(MultiError); ok {
122 | code := handleMultiError(multiErr)
123 | OsExiter(code)
124 | return
125 | }
126 | }
127 |
128 | func handleMultiError(multiErr MultiError) int {
129 | code := 1
130 | for _, merr := range multiErr.Errors() {
131 | if multiErr2, ok := merr.(MultiError); ok {
132 | code = handleMultiError(multiErr2)
133 | } else if merr != nil {
134 | fmt.Fprintln(ErrWriter, merr)
135 | if exitErr, ok := merr.(ExitCoder); ok {
136 | code = exitErr.ExitCode()
137 | }
138 | }
139 | }
140 | return code
141 | }
142 |
--------------------------------------------------------------------------------
/vendor/github.com/urfave/cli/v2/flag_timestamp.go:
--------------------------------------------------------------------------------
1 | package cli
2 |
3 | import (
4 | "flag"
5 | "fmt"
6 | "time"
7 | )
8 |
9 | // Timestamp wrap to satisfy golang's flag interface.
10 | type Timestamp struct {
11 | timestamp *time.Time
12 | hasBeenSet bool
13 | layout string
14 | }
15 |
16 | // Timestamp constructor
17 | func NewTimestamp(timestamp time.Time) *Timestamp {
18 | return &Timestamp{timestamp: ×tamp}
19 | }
20 |
21 | // Set the timestamp value directly
22 | func (t *Timestamp) SetTimestamp(value time.Time) {
23 | if !t.hasBeenSet {
24 | t.timestamp = &value
25 | t.hasBeenSet = true
26 | }
27 | }
28 |
29 | // Set the timestamp string layout for future parsing
30 | func (t *Timestamp) SetLayout(layout string) {
31 | t.layout = layout
32 | }
33 |
34 | // Parses the string value to timestamp
35 | func (t *Timestamp) Set(value string) error {
36 | timestamp, err := time.Parse(t.layout, value)
37 | if err != nil {
38 | return err
39 | }
40 |
41 | t.timestamp = ×tamp
42 | t.hasBeenSet = true
43 | return nil
44 | }
45 |
46 | // String returns a readable representation of this value (for usage defaults)
47 | func (t *Timestamp) String() string {
48 | return fmt.Sprintf("%#v", t.timestamp)
49 | }
50 |
51 | // Value returns the timestamp value stored in the flag
52 | func (t *Timestamp) Value() *time.Time {
53 | return t.timestamp
54 | }
55 |
56 | // Get returns the flag structure
57 | func (t *Timestamp) Get() interface{} {
58 | return *t
59 | }
60 |
61 | // TimestampFlag is a flag with type time
62 | type TimestampFlag struct {
63 | Name string
64 | Aliases []string
65 | Usage string
66 | EnvVars []string
67 | FilePath string
68 | Required bool
69 | Hidden bool
70 | Layout string
71 | Value *Timestamp
72 | DefaultText string
73 | HasBeenSet bool
74 | }
75 |
76 | // IsSet returns whether or not the flag has been set through env or file
77 | func (f *TimestampFlag) IsSet() bool {
78 | return f.HasBeenSet
79 | }
80 |
81 | // String returns a readable representation of this value
82 | // (for usage defaults)
83 | func (f *TimestampFlag) String() string {
84 | return FlagStringer(f)
85 | }
86 |
87 | // Names returns the names of the flag
88 | func (f *TimestampFlag) Names() []string {
89 | return flagNames(f.Name, f.Aliases)
90 | }
91 |
92 | // IsRequired returns whether or not the flag is required
93 | func (f *TimestampFlag) IsRequired() bool {
94 | return f.Required
95 | }
96 |
97 | // TakesValue returns true of the flag takes a value, otherwise false
98 | func (f *TimestampFlag) TakesValue() bool {
99 | return true
100 | }
101 |
102 | // GetUsage returns the usage string for the flag
103 | func (f *TimestampFlag) GetUsage() string {
104 | return f.Usage
105 | }
106 |
107 | // GetValue returns the flags value as string representation and an empty
108 | // string if the flag takes no value at all.
109 | func (f *TimestampFlag) GetValue() string {
110 | if f.Value != nil {
111 | return f.Value.timestamp.String()
112 | }
113 | return ""
114 | }
115 |
116 | // Apply populates the flag given the flag set and environment
117 | func (f *TimestampFlag) Apply(set *flag.FlagSet) error {
118 | if f.Layout == "" {
119 | return fmt.Errorf("timestamp Layout is required")
120 | }
121 | if f.Value == nil {
122 | f.Value = &Timestamp{}
123 | }
124 | f.Value.SetLayout(f.Layout)
125 |
126 | if val, ok := flagFromEnvOrFile(f.EnvVars, f.FilePath); ok {
127 | if err := f.Value.Set(val); err != nil {
128 | return fmt.Errorf("could not parse %q as timestamp value for flag %s: %s", val, f.Name, err)
129 | }
130 | f.HasBeenSet = true
131 | }
132 |
133 | for _, name := range f.Names() {
134 | set.Var(f.Value, name, f.Usage)
135 | }
136 | return nil
137 | }
138 |
139 | // Timestamp gets the timestamp from a flag name
140 | func (c *Context) Timestamp(name string) *time.Time {
141 | if fs := lookupFlagSet(name, c); fs != nil {
142 | return lookupTimestamp(name, fs)
143 | }
144 | return nil
145 | }
146 |
147 | // Fetches the timestamp value from the local timestampWrap
148 | func lookupTimestamp(name string, set *flag.FlagSet) *time.Time {
149 | f := set.Lookup(name)
150 | if f != nil {
151 | return (f.Value.(*Timestamp)).Value()
152 | }
153 | return nil
154 | }
155 |
--------------------------------------------------------------------------------
/vendor/github.com/urfave/cli/v2/template.go:
--------------------------------------------------------------------------------
1 | package cli
2 |
3 | // AppHelpTemplate is the text template for the Default help topic.
4 | // cli.go uses text/template to render templates. You can
5 | // render custom help text by setting this variable.
6 | var AppHelpTemplate = `NAME:
7 | {{.Name}}{{if .Usage}} - {{.Usage}}{{end}}
8 |
9 | USAGE:
10 | {{if .UsageText}}{{.UsageText}}{{else}}{{.HelpName}} {{if .VisibleFlags}}[global options]{{end}}{{if .Commands}} command [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{end}}{{if .Version}}{{if not .HideVersion}}
11 |
12 | VERSION:
13 | {{.Version}}{{end}}{{end}}{{if .Description}}
14 |
15 | DESCRIPTION:
16 | {{.Description | nindent 3 | trim}}{{end}}{{if len .Authors}}
17 |
18 | AUTHOR{{with $length := len .Authors}}{{if ne 1 $length}}S{{end}}{{end}}:
19 | {{range $index, $author := .Authors}}{{if $index}}
20 | {{end}}{{$author}}{{end}}{{end}}{{if .VisibleCommands}}
21 |
22 | COMMANDS:{{range .VisibleCategories}}{{if .Name}}
23 | {{.Name}}:{{range .VisibleCommands}}
24 | {{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{else}}{{range .VisibleCommands}}
25 | {{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{end}}{{end}}{{end}}{{if .VisibleFlags}}
26 |
27 | GLOBAL OPTIONS:
28 | {{range $index, $option := .VisibleFlags}}{{if $index}}
29 | {{end}}{{$option}}{{end}}{{end}}{{if .Copyright}}
30 |
31 | COPYRIGHT:
32 | {{.Copyright}}{{end}}
33 | `
34 |
35 | // CommandHelpTemplate is the text template for the command help topic.
36 | // cli.go uses text/template to render templates. You can
37 | // render custom help text by setting this variable.
38 | var CommandHelpTemplate = `NAME:
39 | {{.HelpName}} - {{.Usage}}
40 |
41 | USAGE:
42 | {{if .UsageText}}{{.UsageText}}{{else}}{{.HelpName}}{{if .VisibleFlags}} [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{end}}{{if .Category}}
43 |
44 | CATEGORY:
45 | {{.Category}}{{end}}{{if .Description}}
46 |
47 | DESCRIPTION:
48 | {{.Description | nindent 3 | trim}}{{end}}{{if .VisibleFlags}}
49 |
50 | OPTIONS:
51 | {{range .VisibleFlags}}{{.}}
52 | {{end}}{{end}}
53 | `
54 |
55 | // SubcommandHelpTemplate is the text template for the subcommand help topic.
56 | // cli.go uses text/template to render templates. You can
57 | // render custom help text by setting this variable.
58 | var SubcommandHelpTemplate = `NAME:
59 | {{.HelpName}} - {{.Usage}}
60 |
61 | USAGE:
62 | {{if .UsageText}}{{.UsageText}}{{else}}{{.HelpName}} command{{if .VisibleFlags}} [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{end}}{{if .Description}}
63 |
64 | DESCRIPTION:
65 | {{.Description | nindent 3 | trim}}{{end}}
66 |
67 | COMMANDS:{{range .VisibleCategories}}{{if .Name}}
68 | {{.Name}}:{{range .VisibleCommands}}
69 | {{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{else}}{{range .VisibleCommands}}
70 | {{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{end}}{{end}}{{if .VisibleFlags}}
71 |
72 | OPTIONS:
73 | {{range .VisibleFlags}}{{.}}
74 | {{end}}{{end}}
75 | `
76 |
77 | var MarkdownDocTemplate = `% {{ .App.Name }} 8
78 |
79 | # NAME
80 |
81 | {{ .App.Name }}{{ if .App.Usage }} - {{ .App.Usage }}{{ end }}
82 |
83 | # SYNOPSIS
84 |
85 | {{ .App.Name }}
86 | {{ if .SynopsisArgs }}
87 | ` + "```" + `
88 | {{ range $v := .SynopsisArgs }}{{ $v }}{{ end }}` + "```" + `
89 | {{ end }}{{ if .App.UsageText }}
90 | # DESCRIPTION
91 |
92 | {{ .App.UsageText }}
93 | {{ end }}
94 | **Usage**:
95 |
96 | ` + "```" + `
97 | {{ .App.Name }} [GLOBAL OPTIONS] command [COMMAND OPTIONS] [ARGUMENTS...]
98 | ` + "```" + `
99 | {{ if .GlobalArgs }}
100 | # GLOBAL OPTIONS
101 | {{ range $v := .GlobalArgs }}
102 | {{ $v }}{{ end }}
103 | {{ end }}{{ if .Commands }}
104 | # COMMANDS
105 | {{ range $v := .Commands }}
106 | {{ $v }}{{ end }}{{ end }}`
107 |
108 | var FishCompletionTemplate = `# {{ .App.Name }} fish shell completion
109 |
110 | function __fish_{{ .App.Name }}_no_subcommand --description 'Test if there has been any subcommand yet'
111 | for i in (commandline -opc)
112 | if contains -- $i{{ range $v := .AllCommands }} {{ $v }}{{ end }}
113 | return 1
114 | end
115 | end
116 | return 0
117 | end
118 |
119 | {{ range $v := .Completions }}{{ $v }}
120 | {{ end }}`
121 |
--------------------------------------------------------------------------------
/vendor/github.com/urfave/cli/v2/flag_int64_slice.go:
--------------------------------------------------------------------------------
1 | package cli
2 |
3 | import (
4 | "encoding/json"
5 | "flag"
6 | "fmt"
7 | "strconv"
8 | "strings"
9 | )
10 |
11 | // Int64Slice wraps []int64 to satisfy flag.Value
12 | type Int64Slice struct {
13 | slice []int64
14 | hasBeenSet bool
15 | }
16 |
17 | // NewInt64Slice makes an *Int64Slice with default values
18 | func NewInt64Slice(defaults ...int64) *Int64Slice {
19 | return &Int64Slice{slice: append([]int64{}, defaults...)}
20 | }
21 |
22 | // Set parses the value into an integer and appends it to the list of values
23 | func (i *Int64Slice) Set(value string) error {
24 | if !i.hasBeenSet {
25 | i.slice = []int64{}
26 | i.hasBeenSet = true
27 | }
28 |
29 | if strings.HasPrefix(value, slPfx) {
30 | // Deserializing assumes overwrite
31 | _ = json.Unmarshal([]byte(strings.Replace(value, slPfx, "", 1)), &i.slice)
32 | i.hasBeenSet = true
33 | return nil
34 | }
35 |
36 | tmp, err := strconv.ParseInt(value, 0, 64)
37 | if err != nil {
38 | return err
39 | }
40 |
41 | i.slice = append(i.slice, tmp)
42 |
43 | return nil
44 | }
45 |
46 | // String returns a readable representation of this value (for usage defaults)
47 | func (i *Int64Slice) String() string {
48 | return fmt.Sprintf("%#v", i.slice)
49 | }
50 |
51 | // Serialize allows Int64Slice to fulfill Serializer
52 | func (i *Int64Slice) Serialize() string {
53 | jsonBytes, _ := json.Marshal(i.slice)
54 | return fmt.Sprintf("%s%s", slPfx, string(jsonBytes))
55 | }
56 |
57 | // Value returns the slice of ints set by this flag
58 | func (i *Int64Slice) Value() []int64 {
59 | return i.slice
60 | }
61 |
62 | // Get returns the slice of ints set by this flag
63 | func (i *Int64Slice) Get() interface{} {
64 | return *i
65 | }
66 |
67 | // Int64SliceFlag is a flag with type *Int64Slice
68 | type Int64SliceFlag struct {
69 | Name string
70 | Aliases []string
71 | Usage string
72 | EnvVars []string
73 | FilePath string
74 | Required bool
75 | Hidden bool
76 | Value *Int64Slice
77 | DefaultText string
78 | HasBeenSet bool
79 | }
80 |
81 | // IsSet returns whether or not the flag has been set through env or file
82 | func (f *Int64SliceFlag) IsSet() bool {
83 | return f.HasBeenSet
84 | }
85 |
86 | // String returns a readable representation of this value
87 | // (for usage defaults)
88 | func (f *Int64SliceFlag) String() string {
89 | return FlagStringer(f)
90 | }
91 |
92 | // Names returns the names of the flag
93 | func (f *Int64SliceFlag) Names() []string {
94 | return flagNames(f.Name, f.Aliases)
95 | }
96 |
97 | // IsRequired returns whether or not the flag is required
98 | func (f *Int64SliceFlag) IsRequired() bool {
99 | return f.Required
100 | }
101 |
102 | // TakesValue returns true of the flag takes a value, otherwise false
103 | func (f *Int64SliceFlag) TakesValue() bool {
104 | return true
105 | }
106 |
107 | // GetUsage returns the usage string for the flag
108 | func (f Int64SliceFlag) GetUsage() string {
109 | return f.Usage
110 | }
111 |
112 | // GetValue returns the flags value as string representation and an empty
113 | // string if the flag takes no value at all.
114 | func (f *Int64SliceFlag) GetValue() string {
115 | if f.Value != nil {
116 | return f.Value.String()
117 | }
118 | return ""
119 | }
120 |
121 | // Apply populates the flag given the flag set and environment
122 | func (f *Int64SliceFlag) Apply(set *flag.FlagSet) error {
123 | if val, ok := flagFromEnvOrFile(f.EnvVars, f.FilePath); ok {
124 | f.Value = &Int64Slice{}
125 |
126 | for _, s := range strings.Split(val, ",") {
127 | if err := f.Value.Set(strings.TrimSpace(s)); err != nil {
128 | return fmt.Errorf("could not parse %q as int64 slice value for flag %s: %s", val, f.Name, err)
129 | }
130 | }
131 |
132 | f.HasBeenSet = true
133 | }
134 |
135 | for _, name := range f.Names() {
136 | if f.Value == nil {
137 | f.Value = &Int64Slice{}
138 | }
139 | set.Var(f.Value, name, f.Usage)
140 | }
141 |
142 | return nil
143 | }
144 |
145 | // Int64Slice looks up the value of a local Int64SliceFlag, returns
146 | // nil if not found
147 | func (c *Context) Int64Slice(name string) []int64 {
148 | return lookupInt64Slice(name, c.flagSet)
149 | }
150 |
151 | func lookupInt64Slice(name string, set *flag.FlagSet) []int64 {
152 | f := set.Lookup(name)
153 | if f != nil {
154 | if slice, ok := f.Value.(*Int64Slice); ok {
155 | return slice.Value()
156 | }
157 | }
158 | return nil
159 | }
160 |
--------------------------------------------------------------------------------
/vendor/github.com/urfave/cli/v2/flag_float64_slice.go:
--------------------------------------------------------------------------------
1 | package cli
2 |
3 | import (
4 | "encoding/json"
5 | "flag"
6 | "fmt"
7 | "strconv"
8 | "strings"
9 | )
10 |
11 | // Float64Slice wraps []float64 to satisfy flag.Value
12 | type Float64Slice struct {
13 | slice []float64
14 | hasBeenSet bool
15 | }
16 |
17 | // NewFloat64Slice makes a *Float64Slice with default values
18 | func NewFloat64Slice(defaults ...float64) *Float64Slice {
19 | return &Float64Slice{slice: append([]float64{}, defaults...)}
20 | }
21 |
22 | // Set parses the value into a float64 and appends it to the list of values
23 | func (f *Float64Slice) Set(value string) error {
24 | if !f.hasBeenSet {
25 | f.slice = []float64{}
26 | f.hasBeenSet = true
27 | }
28 |
29 | if strings.HasPrefix(value, slPfx) {
30 | // Deserializing assumes overwrite
31 | _ = json.Unmarshal([]byte(strings.Replace(value, slPfx, "", 1)), &f.slice)
32 | f.hasBeenSet = true
33 | return nil
34 | }
35 |
36 | tmp, err := strconv.ParseFloat(value, 64)
37 | if err != nil {
38 | return err
39 | }
40 |
41 | f.slice = append(f.slice, tmp)
42 | return nil
43 | }
44 |
45 | // String returns a readable representation of this value (for usage defaults)
46 | func (f *Float64Slice) String() string {
47 | return fmt.Sprintf("%#v", f.slice)
48 | }
49 |
50 | // Serialize allows Float64Slice to fulfill Serializer
51 | func (f *Float64Slice) Serialize() string {
52 | jsonBytes, _ := json.Marshal(f.slice)
53 | return fmt.Sprintf("%s%s", slPfx, string(jsonBytes))
54 | }
55 |
56 | // Value returns the slice of float64s set by this flag
57 | func (f *Float64Slice) Value() []float64 {
58 | return f.slice
59 | }
60 |
61 | // Get returns the slice of float64s set by this flag
62 | func (f *Float64Slice) Get() interface{} {
63 | return *f
64 | }
65 |
66 | // Float64SliceFlag is a flag with type *Float64Slice
67 | type Float64SliceFlag struct {
68 | Name string
69 | Aliases []string
70 | Usage string
71 | EnvVars []string
72 | FilePath string
73 | Required bool
74 | Hidden bool
75 | Value *Float64Slice
76 | DefaultText string
77 | HasBeenSet bool
78 | }
79 |
80 | // IsSet returns whether or not the flag has been set through env or file
81 | func (f *Float64SliceFlag) IsSet() bool {
82 | return f.HasBeenSet
83 | }
84 |
85 | // String returns a readable representation of this value
86 | // (for usage defaults)
87 | func (f *Float64SliceFlag) String() string {
88 | return FlagStringer(f)
89 | }
90 |
91 | // Names returns the names of the flag
92 | func (f *Float64SliceFlag) Names() []string {
93 | return flagNames(f.Name, f.Aliases)
94 | }
95 |
96 | // IsRequired returns whether or not the flag is required
97 | func (f *Float64SliceFlag) IsRequired() bool {
98 | return f.Required
99 | }
100 |
101 | // TakesValue returns true if the flag takes a value, otherwise false
102 | func (f *Float64SliceFlag) TakesValue() bool {
103 | return true
104 | }
105 |
106 | // GetUsage returns the usage string for the flag
107 | func (f *Float64SliceFlag) GetUsage() string {
108 | return f.Usage
109 | }
110 |
111 | // GetValue returns the flags value as string representation and an empty
112 | // string if the flag takes no value at all.
113 | func (f *Float64SliceFlag) GetValue() string {
114 | if f.Value != nil {
115 | return f.Value.String()
116 | }
117 | return ""
118 | }
119 |
120 | // Apply populates the flag given the flag set and environment
121 | func (f *Float64SliceFlag) Apply(set *flag.FlagSet) error {
122 | if val, ok := flagFromEnvOrFile(f.EnvVars, f.FilePath); ok {
123 | if val != "" {
124 | f.Value = &Float64Slice{}
125 |
126 | for _, s := range strings.Split(val, ",") {
127 | if err := f.Value.Set(strings.TrimSpace(s)); err != nil {
128 | return fmt.Errorf("could not parse %q as float64 slice value for flag %s: %s", f.Value, f.Name, err)
129 | }
130 | }
131 |
132 | f.HasBeenSet = true
133 | }
134 | }
135 |
136 | for _, name := range f.Names() {
137 | if f.Value == nil {
138 | f.Value = &Float64Slice{}
139 | }
140 | set.Var(f.Value, name, f.Usage)
141 | }
142 |
143 | return nil
144 | }
145 |
146 | // Float64Slice looks up the value of a local Float64SliceFlag, returns
147 | // nil if not found
148 | func (c *Context) Float64Slice(name string) []float64 {
149 | if fs := lookupFlagSet(name, c); fs != nil {
150 | return lookupFloat64Slice(name, fs)
151 | }
152 | return nil
153 | }
154 |
155 | func lookupFloat64Slice(name string, set *flag.FlagSet) []float64 {
156 | f := set.Lookup(name)
157 | if f != nil {
158 | if slice, ok := f.Value.(*Float64Slice); ok {
159 | return slice.Value()
160 | }
161 | }
162 | return nil
163 | }
164 |
--------------------------------------------------------------------------------
/vendor/github.com/urfave/cli/v2/flag_int_slice.go:
--------------------------------------------------------------------------------
1 | package cli
2 |
3 | import (
4 | "encoding/json"
5 | "flag"
6 | "fmt"
7 | "strconv"
8 | "strings"
9 | )
10 |
11 | // IntSlice wraps []int to satisfy flag.Value
12 | type IntSlice struct {
13 | slice []int
14 | hasBeenSet bool
15 | }
16 |
17 | // NewIntSlice makes an *IntSlice with default values
18 | func NewIntSlice(defaults ...int) *IntSlice {
19 | return &IntSlice{slice: append([]int{}, defaults...)}
20 | }
21 |
22 | // TODO: Consistently have specific Set function for Int64 and Float64 ?
23 | // SetInt directly adds an integer to the list of values
24 | func (i *IntSlice) SetInt(value int) {
25 | if !i.hasBeenSet {
26 | i.slice = []int{}
27 | i.hasBeenSet = true
28 | }
29 |
30 | i.slice = append(i.slice, value)
31 | }
32 |
33 | // Set parses the value into an integer and appends it to the list of values
34 | func (i *IntSlice) Set(value string) error {
35 | if !i.hasBeenSet {
36 | i.slice = []int{}
37 | i.hasBeenSet = true
38 | }
39 |
40 | if strings.HasPrefix(value, slPfx) {
41 | // Deserializing assumes overwrite
42 | _ = json.Unmarshal([]byte(strings.Replace(value, slPfx, "", 1)), &i.slice)
43 | i.hasBeenSet = true
44 | return nil
45 | }
46 |
47 | tmp, err := strconv.ParseInt(value, 0, 64)
48 | if err != nil {
49 | return err
50 | }
51 |
52 | i.slice = append(i.slice, int(tmp))
53 |
54 | return nil
55 | }
56 |
57 | // String returns a readable representation of this value (for usage defaults)
58 | func (i *IntSlice) String() string {
59 | return fmt.Sprintf("%#v", i.slice)
60 | }
61 |
62 | // Serialize allows IntSlice to fulfill Serializer
63 | func (i *IntSlice) Serialize() string {
64 | jsonBytes, _ := json.Marshal(i.slice)
65 | return fmt.Sprintf("%s%s", slPfx, string(jsonBytes))
66 | }
67 |
68 | // Value returns the slice of ints set by this flag
69 | func (i *IntSlice) Value() []int {
70 | return i.slice
71 | }
72 |
73 | // Get returns the slice of ints set by this flag
74 | func (i *IntSlice) Get() interface{} {
75 | return *i
76 | }
77 |
78 | // IntSliceFlag is a flag with type *IntSlice
79 | type IntSliceFlag struct {
80 | Name string
81 | Aliases []string
82 | Usage string
83 | EnvVars []string
84 | FilePath string
85 | Required bool
86 | Hidden bool
87 | Value *IntSlice
88 | DefaultText string
89 | HasBeenSet bool
90 | }
91 |
92 | // IsSet returns whether or not the flag has been set through env or file
93 | func (f *IntSliceFlag) IsSet() bool {
94 | return f.HasBeenSet
95 | }
96 |
97 | // String returns a readable representation of this value
98 | // (for usage defaults)
99 | func (f *IntSliceFlag) String() string {
100 | return FlagStringer(f)
101 | }
102 |
103 | // Names returns the names of the flag
104 | func (f *IntSliceFlag) Names() []string {
105 | return flagNames(f.Name, f.Aliases)
106 | }
107 |
108 | // IsRequired returns whether or not the flag is required
109 | func (f *IntSliceFlag) IsRequired() bool {
110 | return f.Required
111 | }
112 |
113 | // TakesValue returns true of the flag takes a value, otherwise false
114 | func (f *IntSliceFlag) TakesValue() bool {
115 | return true
116 | }
117 |
118 | // GetUsage returns the usage string for the flag
119 | func (f IntSliceFlag) GetUsage() string {
120 | return f.Usage
121 | }
122 |
123 | // GetValue returns the flags value as string representation and an empty
124 | // string if the flag takes no value at all.
125 | func (f *IntSliceFlag) GetValue() string {
126 | if f.Value != nil {
127 | return f.Value.String()
128 | }
129 | return ""
130 | }
131 |
132 | // Apply populates the flag given the flag set and environment
133 | func (f *IntSliceFlag) Apply(set *flag.FlagSet) error {
134 | if val, ok := flagFromEnvOrFile(f.EnvVars, f.FilePath); ok {
135 | f.Value = &IntSlice{}
136 |
137 | for _, s := range strings.Split(val, ",") {
138 | if err := f.Value.Set(strings.TrimSpace(s)); err != nil {
139 | return fmt.Errorf("could not parse %q as int slice value for flag %s: %s", val, f.Name, err)
140 | }
141 | }
142 |
143 | f.HasBeenSet = true
144 | }
145 |
146 | for _, name := range f.Names() {
147 | if f.Value == nil {
148 | f.Value = &IntSlice{}
149 | }
150 | set.Var(f.Value, name, f.Usage)
151 | }
152 |
153 | return nil
154 | }
155 |
156 | // IntSlice looks up the value of a local IntSliceFlag, returns
157 | // nil if not found
158 | func (c *Context) IntSlice(name string) []int {
159 | if fs := lookupFlagSet(name, c); fs != nil {
160 | return lookupIntSlice(name, c.flagSet)
161 | }
162 | return nil
163 | }
164 |
165 | func lookupIntSlice(name string, set *flag.FlagSet) []int {
166 | f := set.Lookup(name)
167 | if f != nil {
168 | if slice, ok := f.Value.(*IntSlice); ok {
169 | return slice.Value()
170 | }
171 | }
172 | return nil
173 | }
174 |
--------------------------------------------------------------------------------
/vendor/github.com/imdario/mergo/doc.go:
--------------------------------------------------------------------------------
1 | // Copyright 2013 Dario Castañé. All rights reserved.
2 | // Copyright 2009 The Go Authors. All rights reserved.
3 | // Use of this source code is governed by a BSD-style
4 | // license that can be found in the LICENSE file.
5 |
6 | /*
7 | A helper to merge structs and maps in Golang. Useful for configuration default values, avoiding messy if-statements.
8 |
9 | Mergo merges same-type structs and maps by setting default values in zero-value fields. Mergo won't merge unexported (private) fields. It will do recursively any exported one. It also won't merge structs inside maps (because they are not addressable using Go reflection).
10 |
11 | Status
12 |
13 | It is ready for production use. It is used in several projects by Docker, Google, The Linux Foundation, VMWare, Shopify, etc.
14 |
15 | Important note
16 |
17 | Please keep in mind that a problematic PR broke 0.3.9. We reverted it in 0.3.10. We consider 0.3.10 as stable but not bug-free. . Also, this version adds suppot for go modules.
18 |
19 | Keep in mind that in 0.3.2, Mergo changed Merge() and Map() signatures to support transformers. We added an optional/variadic argument so that it won't break the existing code.
20 |
21 | If you were using Mergo before April 6th, 2015, please check your project works as intended after updating your local copy with go get -u github.com/imdario/mergo. I apologize for any issue caused by its previous behavior and any future bug that Mergo could cause in existing projects after the change (release 0.2.0).
22 |
23 | Install
24 |
25 | Do your usual installation procedure:
26 |
27 | go get github.com/imdario/mergo
28 |
29 | // use in your .go code
30 | import (
31 | "github.com/imdario/mergo"
32 | )
33 |
34 | Usage
35 |
36 | You can only merge same-type structs with exported fields initialized as zero value of their type and same-types maps. Mergo won't merge unexported (private) fields but will do recursively any exported one. It won't merge empty structs value as they are zero values too. Also, maps will be merged recursively except for structs inside maps (because they are not addressable using Go reflection).
37 |
38 | if err := mergo.Merge(&dst, src); err != nil {
39 | // ...
40 | }
41 |
42 | Also, you can merge overwriting values using the transformer WithOverride.
43 |
44 | if err := mergo.Merge(&dst, src, mergo.WithOverride); err != nil {
45 | // ...
46 | }
47 |
48 | Additionally, you can map a map[string]interface{} to a struct (and otherwise, from struct to map), following the same restrictions as in Merge(). Keys are capitalized to find each corresponding exported field.
49 |
50 | if err := mergo.Map(&dst, srcMap); err != nil {
51 | // ...
52 | }
53 |
54 | Warning: if you map a struct to map, it won't do it recursively. Don't expect Mergo to map struct members of your struct as map[string]interface{}. They will be just assigned as values.
55 |
56 | Here is a nice example:
57 |
58 | package main
59 |
60 | import (
61 | "fmt"
62 | "github.com/imdario/mergo"
63 | )
64 |
65 | type Foo struct {
66 | A string
67 | B int64
68 | }
69 |
70 | func main() {
71 | src := Foo{
72 | A: "one",
73 | B: 2,
74 | }
75 | dest := Foo{
76 | A: "two",
77 | }
78 | mergo.Merge(&dest, src)
79 | fmt.Println(dest)
80 | // Will print
81 | // {two 2}
82 | }
83 |
84 | Transformers
85 |
86 | Transformers allow to merge specific types differently than in the default behavior. In other words, now you can customize how some types are merged. For example, time.Time is a struct; it doesn't have zero value but IsZero can return true because it has fields with zero value. How can we merge a non-zero time.Time?
87 |
88 | package main
89 |
90 | import (
91 | "fmt"
92 | "github.com/imdario/mergo"
93 | "reflect"
94 | "time"
95 | )
96 |
97 | type timeTransformer struct {
98 | }
99 |
100 | func (t timeTransformer) Transformer(typ reflect.Type) func(dst, src reflect.Value) error {
101 | if typ == reflect.TypeOf(time.Time{}) {
102 | return func(dst, src reflect.Value) error {
103 | if dst.CanSet() {
104 | isZero := dst.MethodByName("IsZero")
105 | result := isZero.Call([]reflect.Value{})
106 | if result[0].Bool() {
107 | dst.Set(src)
108 | }
109 | }
110 | return nil
111 | }
112 | }
113 | return nil
114 | }
115 |
116 | type Snapshot struct {
117 | Time time.Time
118 | // ...
119 | }
120 |
121 | func main() {
122 | src := Snapshot{time.Now()}
123 | dest := Snapshot{}
124 | mergo.Merge(&dest, src, mergo.WithTransformers(timeTransformer{}))
125 | fmt.Println(dest)
126 | // Will print
127 | // { 2018-01-12 01:15:00 +0000 UTC m=+0.000000001 }
128 | }
129 |
130 | Contact me
131 |
132 | If I can help you, you have an idea or you are using Mergo in your projects, don't hesitate to drop me a line (or a pull request): https://twitter.com/im_dario
133 |
134 | About
135 |
136 | Written by Dario Castañé: https://da.rio.hn
137 |
138 | License
139 |
140 | BSD 3-Clause license, as Go language.
141 |
142 | */
143 | package mergo
144 |
--------------------------------------------------------------------------------
/vendor/github.com/urfave/cli/v2/fish.go:
--------------------------------------------------------------------------------
1 | package cli
2 |
3 | import (
4 | "bytes"
5 | "fmt"
6 | "io"
7 | "strings"
8 | "text/template"
9 | )
10 |
11 | // ToFishCompletion creates a fish completion string for the `*App`
12 | // The function errors if either parsing or writing of the string fails.
13 | func (a *App) ToFishCompletion() (string, error) {
14 | var w bytes.Buffer
15 | if err := a.writeFishCompletionTemplate(&w); err != nil {
16 | return "", err
17 | }
18 | return w.String(), nil
19 | }
20 |
21 | type fishCompletionTemplate struct {
22 | App *App
23 | Completions []string
24 | AllCommands []string
25 | }
26 |
27 | func (a *App) writeFishCompletionTemplate(w io.Writer) error {
28 | const name = "cli"
29 | t, err := template.New(name).Parse(FishCompletionTemplate)
30 | if err != nil {
31 | return err
32 | }
33 | allCommands := []string{}
34 |
35 | // Add global flags
36 | completions := a.prepareFishFlags(a.VisibleFlags(), allCommands)
37 |
38 | // Add help flag
39 | if !a.HideHelp {
40 | completions = append(
41 | completions,
42 | a.prepareFishFlags([]Flag{HelpFlag}, allCommands)...,
43 | )
44 | }
45 |
46 | // Add version flag
47 | if !a.HideVersion {
48 | completions = append(
49 | completions,
50 | a.prepareFishFlags([]Flag{VersionFlag}, allCommands)...,
51 | )
52 | }
53 |
54 | // Add commands and their flags
55 | completions = append(
56 | completions,
57 | a.prepareFishCommands(a.VisibleCommands(), &allCommands, []string{})...,
58 | )
59 |
60 | return t.ExecuteTemplate(w, name, &fishCompletionTemplate{
61 | App: a,
62 | Completions: completions,
63 | AllCommands: allCommands,
64 | })
65 | }
66 |
67 | func (a *App) prepareFishCommands(commands []*Command, allCommands *[]string, previousCommands []string) []string {
68 | completions := []string{}
69 | for _, command := range commands {
70 | if command.Hidden {
71 | continue
72 | }
73 |
74 | var completion strings.Builder
75 | completion.WriteString(fmt.Sprintf(
76 | "complete -r -c %s -n '%s' -a '%s'",
77 | a.Name,
78 | a.fishSubcommandHelper(previousCommands),
79 | strings.Join(command.Names(), " "),
80 | ))
81 |
82 | if command.Usage != "" {
83 | completion.WriteString(fmt.Sprintf(" -d '%s'",
84 | escapeSingleQuotes(command.Usage)))
85 | }
86 |
87 | if !command.HideHelp {
88 | completions = append(
89 | completions,
90 | a.prepareFishFlags([]Flag{HelpFlag}, command.Names())...,
91 | )
92 | }
93 |
94 | *allCommands = append(*allCommands, command.Names()...)
95 | completions = append(completions, completion.String())
96 | completions = append(
97 | completions,
98 | a.prepareFishFlags(command.Flags, command.Names())...,
99 | )
100 |
101 | // recursevly iterate subcommands
102 | if len(command.Subcommands) > 0 {
103 | completions = append(
104 | completions,
105 | a.prepareFishCommands(
106 | command.Subcommands, allCommands, command.Names(),
107 | )...,
108 | )
109 | }
110 | }
111 |
112 | return completions
113 | }
114 |
115 | func (a *App) prepareFishFlags(flags []Flag, previousCommands []string) []string {
116 | completions := []string{}
117 | for _, f := range flags {
118 | flag, ok := f.(DocGenerationFlag)
119 | if !ok {
120 | continue
121 | }
122 |
123 | completion := &strings.Builder{}
124 | completion.WriteString(fmt.Sprintf(
125 | "complete -c %s -n '%s'",
126 | a.Name,
127 | a.fishSubcommandHelper(previousCommands),
128 | ))
129 |
130 | fishAddFileFlag(f, completion)
131 |
132 | for idx, opt := range flag.Names() {
133 | if idx == 0 {
134 | completion.WriteString(fmt.Sprintf(
135 | " -l %s", strings.TrimSpace(opt),
136 | ))
137 | } else {
138 | completion.WriteString(fmt.Sprintf(
139 | " -s %s", strings.TrimSpace(opt),
140 | ))
141 |
142 | }
143 | }
144 |
145 | if flag.TakesValue() {
146 | completion.WriteString(" -r")
147 | }
148 |
149 | if flag.GetUsage() != "" {
150 | completion.WriteString(fmt.Sprintf(" -d '%s'",
151 | escapeSingleQuotes(flag.GetUsage())))
152 | }
153 |
154 | completions = append(completions, completion.String())
155 | }
156 |
157 | return completions
158 | }
159 |
160 | func fishAddFileFlag(flag Flag, completion *strings.Builder) {
161 | switch f := flag.(type) {
162 | case *GenericFlag:
163 | if f.TakesFile {
164 | return
165 | }
166 | case *StringFlag:
167 | if f.TakesFile {
168 | return
169 | }
170 | case *StringSliceFlag:
171 | if f.TakesFile {
172 | return
173 | }
174 | case *PathFlag:
175 | if f.TakesFile {
176 | return
177 | }
178 | }
179 | completion.WriteString(" -f")
180 | }
181 |
182 | func (a *App) fishSubcommandHelper(allCommands []string) string {
183 | fishHelper := fmt.Sprintf("__fish_%s_no_subcommand", a.Name)
184 | if len(allCommands) > 0 {
185 | fishHelper = fmt.Sprintf(
186 | "__fish_seen_subcommand_from %s",
187 | strings.Join(allCommands, " "),
188 | )
189 | }
190 | return fishHelper
191 |
192 | }
193 |
194 | func escapeSingleQuotes(input string) string {
195 | return strings.Replace(input, `'`, `\'`, -1)
196 | }
197 |
--------------------------------------------------------------------------------
/vendor/github.com/urfave/cli/v2/flag_string_slice.go:
--------------------------------------------------------------------------------
1 | package cli
2 |
3 | import (
4 | "encoding/json"
5 | "flag"
6 | "fmt"
7 | "strings"
8 | )
9 |
10 | // StringSlice wraps a []string to satisfy flag.Value
11 | type StringSlice struct {
12 | slice []string
13 | hasBeenSet bool
14 | }
15 |
16 | // NewStringSlice creates a *StringSlice with default values
17 | func NewStringSlice(defaults ...string) *StringSlice {
18 | return &StringSlice{slice: append([]string{}, defaults...)}
19 | }
20 |
21 | // Set appends the string value to the list of values
22 | func (s *StringSlice) Set(value string) error {
23 | if !s.hasBeenSet {
24 | s.slice = []string{}
25 | s.hasBeenSet = true
26 | }
27 |
28 | if strings.HasPrefix(value, slPfx) {
29 | // Deserializing assumes overwrite
30 | _ = json.Unmarshal([]byte(strings.Replace(value, slPfx, "", 1)), &s.slice)
31 | s.hasBeenSet = true
32 | return nil
33 | }
34 |
35 | s.slice = append(s.slice, value)
36 |
37 | return nil
38 | }
39 |
40 | // String returns a readable representation of this value (for usage defaults)
41 | func (s *StringSlice) String() string {
42 | return fmt.Sprintf("%s", s.slice)
43 | }
44 |
45 | // Serialize allows StringSlice to fulfill Serializer
46 | func (s *StringSlice) Serialize() string {
47 | jsonBytes, _ := json.Marshal(s.slice)
48 | return fmt.Sprintf("%s%s", slPfx, string(jsonBytes))
49 | }
50 |
51 | // Value returns the slice of strings set by this flag
52 | func (s *StringSlice) Value() []string {
53 | return s.slice
54 | }
55 |
56 | // Get returns the slice of strings set by this flag
57 | func (s *StringSlice) Get() interface{} {
58 | return *s
59 | }
60 |
61 | // StringSliceFlag is a flag with type *StringSlice
62 | type StringSliceFlag struct {
63 | Name string
64 | Aliases []string
65 | Usage string
66 | EnvVars []string
67 | FilePath string
68 | Required bool
69 | Hidden bool
70 | TakesFile bool
71 | Value *StringSlice
72 | DefaultText string
73 | HasBeenSet bool
74 | Destination *StringSlice
75 | }
76 |
77 | // IsSet returns whether or not the flag has been set through env or file
78 | func (f *StringSliceFlag) IsSet() bool {
79 | return f.HasBeenSet
80 | }
81 |
82 | // String returns a readable representation of this value
83 | // (for usage defaults)
84 | func (f *StringSliceFlag) String() string {
85 | return FlagStringer(f)
86 | }
87 |
88 | // Names returns the names of the flag
89 | func (f *StringSliceFlag) Names() []string {
90 | return flagNames(f.Name, f.Aliases)
91 | }
92 |
93 | // IsRequired returns whether or not the flag is required
94 | func (f *StringSliceFlag) IsRequired() bool {
95 | return f.Required
96 | }
97 |
98 | // TakesValue returns true of the flag takes a value, otherwise false
99 | func (f *StringSliceFlag) TakesValue() bool {
100 | return true
101 | }
102 |
103 | // GetUsage returns the usage string for the flag
104 | func (f *StringSliceFlag) GetUsage() string {
105 | return f.Usage
106 | }
107 |
108 | // GetValue returns the flags value as string representation and an empty
109 | // string if the flag takes no value at all.
110 | func (f *StringSliceFlag) GetValue() string {
111 | if f.Value != nil {
112 | return f.Value.String()
113 | }
114 | return ""
115 | }
116 |
117 | // Apply populates the flag given the flag set and environment
118 | func (f *StringSliceFlag) Apply(set *flag.FlagSet) error {
119 |
120 | if f.Destination != nil && f.Value != nil {
121 | f.Destination.slice = make([]string, len(f.Value.slice))
122 | copy(f.Destination.slice, f.Value.slice)
123 |
124 | }
125 |
126 | if val, ok := flagFromEnvOrFile(f.EnvVars, f.FilePath); ok {
127 | if f.Value == nil {
128 | f.Value = &StringSlice{}
129 | }
130 | destination := f.Value
131 | if f.Destination != nil {
132 | destination = f.Destination
133 | }
134 |
135 | for _, s := range strings.Split(val, ",") {
136 | if err := destination.Set(strings.TrimSpace(s)); err != nil {
137 | return fmt.Errorf("could not parse %q as string value for flag %s: %s", val, f.Name, err)
138 | }
139 | }
140 |
141 | // Set this to false so that we reset the slice if we then set values from
142 | // flags that have already been set by the environment.
143 | destination.hasBeenSet = false
144 | f.HasBeenSet = true
145 | }
146 |
147 | for _, name := range f.Names() {
148 | if f.Value == nil {
149 | f.Value = &StringSlice{}
150 | }
151 |
152 | if f.Destination != nil {
153 | set.Var(f.Destination, name, f.Usage)
154 | continue
155 | }
156 |
157 | set.Var(f.Value, name, f.Usage)
158 | }
159 |
160 | return nil
161 | }
162 |
163 | // StringSlice looks up the value of a local StringSliceFlag, returns
164 | // nil if not found
165 | func (c *Context) StringSlice(name string) []string {
166 | if fs := lookupFlagSet(name, c); fs != nil {
167 | return lookupStringSlice(name, fs)
168 | }
169 | return nil
170 | }
171 |
172 | func lookupStringSlice(name string, set *flag.FlagSet) []string {
173 | f := set.Lookup(name)
174 | if f != nil {
175 | if slice, ok := f.Value.(*StringSlice); ok {
176 | return slice.Value()
177 | }
178 | }
179 | return nil
180 | }
181 |
--------------------------------------------------------------------------------
/vendor/gopkg.in/yaml.v2/yamlprivateh.go:
--------------------------------------------------------------------------------
1 | package yaml
2 |
3 | const (
4 | // The size of the input raw buffer.
5 | input_raw_buffer_size = 512
6 |
7 | // The size of the input buffer.
8 | // It should be possible to decode the whole raw buffer.
9 | input_buffer_size = input_raw_buffer_size * 3
10 |
11 | // The size of the output buffer.
12 | output_buffer_size = 128
13 |
14 | // The size of the output raw buffer.
15 | // It should be possible to encode the whole output buffer.
16 | output_raw_buffer_size = (output_buffer_size*2 + 2)
17 |
18 | // The size of other stacks and queues.
19 | initial_stack_size = 16
20 | initial_queue_size = 16
21 | initial_string_size = 16
22 | )
23 |
24 | // Check if the character at the specified position is an alphabetical
25 | // character, a digit, '_', or '-'.
26 | func is_alpha(b []byte, i int) bool {
27 | return b[i] >= '0' && b[i] <= '9' || b[i] >= 'A' && b[i] <= 'Z' || b[i] >= 'a' && b[i] <= 'z' || b[i] == '_' || b[i] == '-'
28 | }
29 |
30 | // Check if the character at the specified position is a digit.
31 | func is_digit(b []byte, i int) bool {
32 | return b[i] >= '0' && b[i] <= '9'
33 | }
34 |
35 | // Get the value of a digit.
36 | func as_digit(b []byte, i int) int {
37 | return int(b[i]) - '0'
38 | }
39 |
40 | // Check if the character at the specified position is a hex-digit.
41 | func is_hex(b []byte, i int) bool {
42 | return b[i] >= '0' && b[i] <= '9' || b[i] >= 'A' && b[i] <= 'F' || b[i] >= 'a' && b[i] <= 'f'
43 | }
44 |
45 | // Get the value of a hex-digit.
46 | func as_hex(b []byte, i int) int {
47 | bi := b[i]
48 | if bi >= 'A' && bi <= 'F' {
49 | return int(bi) - 'A' + 10
50 | }
51 | if bi >= 'a' && bi <= 'f' {
52 | return int(bi) - 'a' + 10
53 | }
54 | return int(bi) - '0'
55 | }
56 |
57 | // Check if the character is ASCII.
58 | func is_ascii(b []byte, i int) bool {
59 | return b[i] <= 0x7F
60 | }
61 |
62 | // Check if the character at the start of the buffer can be printed unescaped.
63 | func is_printable(b []byte, i int) bool {
64 | return ((b[i] == 0x0A) || // . == #x0A
65 | (b[i] >= 0x20 && b[i] <= 0x7E) || // #x20 <= . <= #x7E
66 | (b[i] == 0xC2 && b[i+1] >= 0xA0) || // #0xA0 <= . <= #xD7FF
67 | (b[i] > 0xC2 && b[i] < 0xED) ||
68 | (b[i] == 0xED && b[i+1] < 0xA0) ||
69 | (b[i] == 0xEE) ||
70 | (b[i] == 0xEF && // #xE000 <= . <= #xFFFD
71 | !(b[i+1] == 0xBB && b[i+2] == 0xBF) && // && . != #xFEFF
72 | !(b[i+1] == 0xBF && (b[i+2] == 0xBE || b[i+2] == 0xBF))))
73 | }
74 |
75 | // Check if the character at the specified position is NUL.
76 | func is_z(b []byte, i int) bool {
77 | return b[i] == 0x00
78 | }
79 |
80 | // Check if the beginning of the buffer is a BOM.
81 | func is_bom(b []byte, i int) bool {
82 | return b[0] == 0xEF && b[1] == 0xBB && b[2] == 0xBF
83 | }
84 |
85 | // Check if the character at the specified position is space.
86 | func is_space(b []byte, i int) bool {
87 | return b[i] == ' '
88 | }
89 |
90 | // Check if the character at the specified position is tab.
91 | func is_tab(b []byte, i int) bool {
92 | return b[i] == '\t'
93 | }
94 |
95 | // Check if the character at the specified position is blank (space or tab).
96 | func is_blank(b []byte, i int) bool {
97 | //return is_space(b, i) || is_tab(b, i)
98 | return b[i] == ' ' || b[i] == '\t'
99 | }
100 |
101 | // Check if the character at the specified position is a line break.
102 | func is_break(b []byte, i int) bool {
103 | return (b[i] == '\r' || // CR (#xD)
104 | b[i] == '\n' || // LF (#xA)
105 | b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85)
106 | b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028)
107 | b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9) // PS (#x2029)
108 | }
109 |
110 | func is_crlf(b []byte, i int) bool {
111 | return b[i] == '\r' && b[i+1] == '\n'
112 | }
113 |
114 | // Check if the character is a line break or NUL.
115 | func is_breakz(b []byte, i int) bool {
116 | //return is_break(b, i) || is_z(b, i)
117 | return ( // is_break:
118 | b[i] == '\r' || // CR (#xD)
119 | b[i] == '\n' || // LF (#xA)
120 | b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85)
121 | b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028)
122 | b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029)
123 | // is_z:
124 | b[i] == 0)
125 | }
126 |
127 | // Check if the character is a line break, space, or NUL.
128 | func is_spacez(b []byte, i int) bool {
129 | //return is_space(b, i) || is_breakz(b, i)
130 | return ( // is_space:
131 | b[i] == ' ' ||
132 | // is_breakz:
133 | b[i] == '\r' || // CR (#xD)
134 | b[i] == '\n' || // LF (#xA)
135 | b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85)
136 | b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028)
137 | b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029)
138 | b[i] == 0)
139 | }
140 |
141 | // Check if the character is a line break, space, tab, or NUL.
142 | func is_blankz(b []byte, i int) bool {
143 | //return is_blank(b, i) || is_breakz(b, i)
144 | return ( // is_blank:
145 | b[i] == ' ' || b[i] == '\t' ||
146 | // is_breakz:
147 | b[i] == '\r' || // CR (#xD)
148 | b[i] == '\n' || // LF (#xA)
149 | b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85)
150 | b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028)
151 | b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029)
152 | b[i] == 0)
153 | }
154 |
155 | // Determine the width of the character.
156 | func width(b byte) int {
157 | // Don't replace these by a switch without first
158 | // confirming that it is being inlined.
159 | if b&0x80 == 0x00 {
160 | return 1
161 | }
162 | if b&0xE0 == 0xC0 {
163 | return 2
164 | }
165 | if b&0xF0 == 0xE0 {
166 | return 3
167 | }
168 | if b&0xF8 == 0xF0 {
169 | return 4
170 | }
171 | return 0
172 |
173 | }
174 |
--------------------------------------------------------------------------------
/examples/functions/functions.txt.tmpl:
--------------------------------------------------------------------------------
1 | line {{next}} started = {{started}}
2 | line {{next}} debugging = {{debug_toggle}}
3 | line {{next}} debugging = {{if debugging}}debugging{{end}}
4 | line {{next}} debug_toggle = {{debug_toggle}}
5 | line {{next}} debugging = {{if debugging}}debugging{{end}}
6 | line {{next}} debug = {{debug "message"}}
7 | line {{next}} command_line = {{command_line}}
8 | line {{next}} RENDERIZER_VERSION = {{environment "RENDERIZER_VERSION" | dirname}}
9 | line {{next}} ip_math = {{ip_math "[-1].[+2].[-3].[+1,%10]" "193.166.3.39"}}
10 | line {{next}} ip4_inc = {{ip4_inc 2 -3 "192.168.3.0"}}
11 | line {{next}} ip4_next = {{ip4_next 2 0 4 "192.168.3.0"}}
12 | line {{next}} ip4_prev = {{ip4_prev 2 1 4 "192.168.1.0"}}
13 | line {{next}} ip_ints = {{ip_ints "192.168.1.0" | ip4_add 2 0 4 3}}
14 | line {{next}} ip_ints = {{ip_ints "192.168.1.0" | ip4_add 2 0 4 3 | ip4_join}}
15 | line {{next}} TODO = {{ip6_inc 2 1 "1111:2222:3333:4444:5555:6666:7777:8888"}}
16 | line {{next}} TODO = {{ip6_next 2 0 4 "1111:2222:3333:4444:5555:6666:7777:8888"}}
17 | line {{next}} TODO = {{ip6_prev 2 0 4 "1111:2222:3333:4444:5555:6666:7777:8888"}}
18 | line {{next}} TODO = {{ip_ints "1111:2222:3333:4444:5555:6666:7777:8888" | ip6_add 2 0 4 3}}
19 | line {{next}} TODO = {{ip_ints "1111:2222:3333:4444:5555:6666:7777:8888" | ip6_join }}
20 | line {{next}} TODO = { {cidr_next} }
21 | line {{next}} ip_ints = {{ip_ints "192.168.0.0"}}
22 | line {{next}} ip_split = {{ip_split "1111:2222:3333:4444:5555:6666:7777:8888"}}
23 | line {{next}} ip_split = {{ip_split "1111:2222:3333:4444:5555:6666:7777:8888" | to_int 16 }}
24 | line {{next}} ip_split = {{ip_split "192.168.0.0" | dec_to_int}}
25 | line {{next}} ip_split = {{ip_split "1111:2222:3333:4444:5555:6666:7777:8888" | hex_to_int}}
26 | line {{next}} ip_split = {{ip_split "1111:2222:3333:4444:5555:6666:7777:8888" | hex_to_int | from_int "%04x" | join "."}}
27 | line {{next}} ip_split = {{ip_split "192.168.0.0" | dec_to_int | from_int "%d" | join "."}}
28 | line {{next}} ip_split = {{ip_split "1111:2222:3333:4444:5555:6666:7777:8888" | iindex 1}}
29 | line {{next}} ip_split = {{ip_split "1111:2222:3333:4444:5555:6666:7777:8888" | hex_to_int | iindex 1}}
30 | line {{next}} iindex = {{"1111:2222:3333:4444:5555:6666:7777:8888" | iindex 4}}
31 | line {{next}} split = {{split "0" "1111:2222:3333:4444:5555:6666:7777:8888"}}
32 | line {{next}} substr = {{substr 4 10 "1111:2222:3333:4444:5555:6666:7777:8888"}}
33 | line {{next}} replace = {{replace "1111:2222:3333:4444:5555:6666:7777:8888" ":" " " 3}}
34 | line {{next}} replace_ = {{"1111:2222:3333:4444:5555:6666:7777:8888" | replace_ 3 ":" " "}}
35 | line {{next}} trim = {{trim "abctrimmedxyz" "abcxyz"}}
36 | line {{next}} trim_ = {{"abctrimmedxyz" | trim_ "abcxyz"}}
37 | line {{next}} trim_left = {{trim_left "abctrimmedxyz" "abcxyz"}}
38 | line {{next}} trim_left_ = {{"abctrimmedxyz" | trim_left_ "abcxyz"}}
39 | line {{next}} trim_right = {{trim_right "abctrimmedxyz" "abcxyz"}}
40 | line {{next}} trim_right_ = {{"abctrimmedxyz" | trim_right_ "abcxyz"}}
41 | line {{next}} keynext A = {{keynext "A"}}
42 | line {{next}} keynext B = {{keynext "B"}}
43 | line {{next}} keynext A = {{keynext "A"}}
44 | line {{next}} inc = 1 + 5 + 4 = {{4 | inc 1 5}}
45 | line {{next}} add = 7 + 3 = {{add 3 7}}
46 | line {{next}} sub = 13 - 3 = {{sub 3 13}}
47 | line {{next}} mul = 5 * 2 = {{mul 2 5}}
48 | line {{next}} div = 20 / 2 = {{div 2 20}}
49 | line {{next}} mod = 12345 % 10 = {{mod 10 12345}}
50 | line {{next}} rand = {{rand}}
51 | line {{next}} lower = {{lower "LOWER"}}
52 | line {{next}} upper = {{upper "upper"}}
53 | line {{next}} title = {{title "this is a title from lowercase"}}
54 | line {{next}} title = {{title "THIS IS A TITLE FROM UPPERCASE"}}
55 | line {{next}} initcap = {{initcap "this is initcap from lowercase"}}
56 | line {{next}} initcap = {{initcap "THIS IS INITCAP FROM UPPERCASE"}}
57 | line {{next}} cleanser = {{cleanser "[^works]" "abcdefghijklmnopqrstuvwxyz"}}
58 | line {{next}} cleanse = [{{cleanse " abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ "}}]
59 | line {{next}} cleanse = {{cleanse "WOR1234567890KS"}}
60 | line {{next}} cleanse = {{cleanse "WOR!@#$%^&*()KS"}}
61 | line {{next}} cleanse = {{cleanse "WOR`~-=_+[]{};':\",.<>/?KS"}}
62 | line {{next}} cleanse = {{cleanse "zaq!xsw@cde#vfr$bgt%nhy^mju&,ki*.lo(/;p)"}}
63 |
64 | line {{next}} dirname = {{dirname "a/b/c/d"}}
65 | line {{next}} dirname = {{dirname "/a/b/c/d"}}
66 | line {{next}} dirname = {{dirname "d"}}
67 | line {{next}} dirname = {{dirname ""}}
68 | line {{next}} basename = {{environment "PWD" | basename}}
69 | line {{next}} basename = {{basename "/a/b/c"}}
70 | line {{next}} basename = {{basename "/a/b/c.ext"}}
71 | line {{next}} basename = {{basename "/a/b/c.ext" "ext"}}
72 | line {{next}} basename = {{basename "c.ext.xyz.last"}}
73 | line {{next}} basename = {{basename "c.ext.xyz.last" "last"}}
74 | line {{next}} basename = {{basename "c.ext.xyz.last" "last" "xyz"}}
75 | line {{next}} basename = {{basename "c.ext.xyz.last" "last" "xyz" "ext"}}
76 |
77 | line {{next}} now = {{now}}
78 | line {{next}} pausing 1s = {{pause 1000}}
79 | line {{next}} now = {{now}}
80 | line {{next}} started = {{started}}
81 |
--------------------------------------------------------------------------------
/vendor/github.com/imdario/mergo/map.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 Dario Castañé. All rights reserved.
2 | // Copyright 2009 The Go Authors. All rights reserved.
3 | // Use of this source code is governed by a BSD-style
4 | // license that can be found in the LICENSE file.
5 |
6 | // Based on src/pkg/reflect/deepequal.go from official
7 | // golang's stdlib.
8 |
9 | package mergo
10 |
11 | import (
12 | "fmt"
13 | "reflect"
14 | "unicode"
15 | "unicode/utf8"
16 | )
17 |
18 | func changeInitialCase(s string, mapper func(rune) rune) string {
19 | if s == "" {
20 | return s
21 | }
22 | r, n := utf8.DecodeRuneInString(s)
23 | return string(mapper(r)) + s[n:]
24 | }
25 |
26 | func isExported(field reflect.StructField) bool {
27 | r, _ := utf8.DecodeRuneInString(field.Name)
28 | return r >= 'A' && r <= 'Z'
29 | }
30 |
31 | // Traverses recursively both values, assigning src's fields values to dst.
32 | // The map argument tracks comparisons that have already been seen, which allows
33 | // short circuiting on recursive types.
34 | func deepMap(dst, src reflect.Value, visited map[uintptr]*visit, depth int, config *Config) (err error) {
35 | overwrite := config.Overwrite
36 | if dst.CanAddr() {
37 | addr := dst.UnsafeAddr()
38 | h := 17 * addr
39 | seen := visited[h]
40 | typ := dst.Type()
41 | for p := seen; p != nil; p = p.next {
42 | if p.ptr == addr && p.typ == typ {
43 | return nil
44 | }
45 | }
46 | // Remember, remember...
47 | visited[h] = &visit{addr, typ, seen}
48 | }
49 | zeroValue := reflect.Value{}
50 | switch dst.Kind() {
51 | case reflect.Map:
52 | dstMap := dst.Interface().(map[string]interface{})
53 | for i, n := 0, src.NumField(); i < n; i++ {
54 | srcType := src.Type()
55 | field := srcType.Field(i)
56 | if !isExported(field) {
57 | continue
58 | }
59 | fieldName := field.Name
60 | fieldName = changeInitialCase(fieldName, unicode.ToLower)
61 | if v, ok := dstMap[fieldName]; !ok || (isEmptyValue(reflect.ValueOf(v)) || overwrite) {
62 | dstMap[fieldName] = src.Field(i).Interface()
63 | }
64 | }
65 | case reflect.Ptr:
66 | if dst.IsNil() {
67 | v := reflect.New(dst.Type().Elem())
68 | dst.Set(v)
69 | }
70 | dst = dst.Elem()
71 | fallthrough
72 | case reflect.Struct:
73 | srcMap := src.Interface().(map[string]interface{})
74 | for key := range srcMap {
75 | config.overwriteWithEmptyValue = true
76 | srcValue := srcMap[key]
77 | fieldName := changeInitialCase(key, unicode.ToUpper)
78 | dstElement := dst.FieldByName(fieldName)
79 | if dstElement == zeroValue {
80 | // We discard it because the field doesn't exist.
81 | continue
82 | }
83 | srcElement := reflect.ValueOf(srcValue)
84 | dstKind := dstElement.Kind()
85 | srcKind := srcElement.Kind()
86 | if srcKind == reflect.Ptr && dstKind != reflect.Ptr {
87 | srcElement = srcElement.Elem()
88 | srcKind = reflect.TypeOf(srcElement.Interface()).Kind()
89 | } else if dstKind == reflect.Ptr {
90 | // Can this work? I guess it can't.
91 | if srcKind != reflect.Ptr && srcElement.CanAddr() {
92 | srcPtr := srcElement.Addr()
93 | srcElement = reflect.ValueOf(srcPtr)
94 | srcKind = reflect.Ptr
95 | }
96 | }
97 |
98 | if !srcElement.IsValid() {
99 | continue
100 | }
101 | if srcKind == dstKind {
102 | if err = deepMerge(dstElement, srcElement, visited, depth+1, config); err != nil {
103 | return
104 | }
105 | } else if dstKind == reflect.Interface && dstElement.Kind() == reflect.Interface {
106 | if err = deepMerge(dstElement, srcElement, visited, depth+1, config); err != nil {
107 | return
108 | }
109 | } else if srcKind == reflect.Map {
110 | if err = deepMap(dstElement, srcElement, visited, depth+1, config); err != nil {
111 | return
112 | }
113 | } else {
114 | return fmt.Errorf("type mismatch on %s field: found %v, expected %v", fieldName, srcKind, dstKind)
115 | }
116 | }
117 | }
118 | return
119 | }
120 |
121 | // Map sets fields' values in dst from src.
122 | // src can be a map with string keys or a struct. dst must be the opposite:
123 | // if src is a map, dst must be a valid pointer to struct. If src is a struct,
124 | // dst must be map[string]interface{}.
125 | // It won't merge unexported (private) fields and will do recursively
126 | // any exported field.
127 | // If dst is a map, keys will be src fields' names in lower camel case.
128 | // Missing key in src that doesn't match a field in dst will be skipped. This
129 | // doesn't apply if dst is a map.
130 | // This is separated method from Merge because it is cleaner and it keeps sane
131 | // semantics: merging equal types, mapping different (restricted) types.
132 | func Map(dst, src interface{}, opts ...func(*Config)) error {
133 | return _map(dst, src, opts...)
134 | }
135 |
136 | // MapWithOverwrite will do the same as Map except that non-empty dst attributes will be overridden by
137 | // non-empty src attribute values.
138 | // Deprecated: Use Map(…) with WithOverride
139 | func MapWithOverwrite(dst, src interface{}, opts ...func(*Config)) error {
140 | return _map(dst, src, append(opts, WithOverride)...)
141 | }
142 |
143 | func _map(dst, src interface{}, opts ...func(*Config)) error {
144 | if dst != nil && reflect.ValueOf(dst).Kind() != reflect.Ptr {
145 | return ErrNonPointerAgument
146 | }
147 | var (
148 | vDst, vSrc reflect.Value
149 | err error
150 | )
151 | config := &Config{}
152 |
153 | for _, opt := range opts {
154 | opt(config)
155 | }
156 |
157 | if vDst, vSrc, err = resolveValues(dst, src); err != nil {
158 | return err
159 | }
160 | // To be friction-less, we redirect equal-type arguments
161 | // to deepMerge. Only because arguments can be anything.
162 | if vSrc.Kind() == vDst.Kind() {
163 | return deepMerge(vDst, vSrc, make(map[uintptr]*visit), 0, config)
164 | }
165 | switch vSrc.Kind() {
166 | case reflect.Struct:
167 | if vDst.Kind() != reflect.Map {
168 | return ErrExpectedMapAsDestination
169 | }
170 | case reflect.Map:
171 | if vDst.Kind() != reflect.Struct {
172 | return ErrExpectedStructAsDestination
173 | }
174 | default:
175 | return ErrNotSupported
176 | }
177 | return deepMap(vDst, vSrc, make(map[uintptr]*visit), 0, config)
178 | }
179 |
--------------------------------------------------------------------------------
/vendor/github.com/urfave/cli/v2/context.go:
--------------------------------------------------------------------------------
1 | package cli
2 |
3 | import (
4 | "context"
5 | "errors"
6 | "flag"
7 | "fmt"
8 | "strings"
9 | )
10 |
11 | // Context is a type that is passed through to
12 | // each Handler action in a cli application. Context
13 | // can be used to retrieve context-specific args and
14 | // parsed command-line options.
15 | type Context struct {
16 | context.Context
17 | App *App
18 | Command *Command
19 | shellComplete bool
20 | flagSet *flag.FlagSet
21 | parentContext *Context
22 | }
23 |
24 | // NewContext creates a new context. For use in when invoking an App or Command action.
25 | func NewContext(app *App, set *flag.FlagSet, parentCtx *Context) *Context {
26 | c := &Context{App: app, flagSet: set, parentContext: parentCtx}
27 | if parentCtx != nil {
28 | c.Context = parentCtx.Context
29 | c.shellComplete = parentCtx.shellComplete
30 | if parentCtx.flagSet == nil {
31 | parentCtx.flagSet = &flag.FlagSet{}
32 | }
33 | }
34 |
35 | c.Command = &Command{}
36 |
37 | if c.Context == nil {
38 | c.Context = context.Background()
39 | }
40 |
41 | return c
42 | }
43 |
44 | // NumFlags returns the number of flags set
45 | func (c *Context) NumFlags() int {
46 | return c.flagSet.NFlag()
47 | }
48 |
49 | // Set sets a context flag to a value.
50 | func (c *Context) Set(name, value string) error {
51 | return c.flagSet.Set(name, value)
52 | }
53 |
54 | // IsSet determines if the flag was actually set
55 | func (c *Context) IsSet(name string) bool {
56 | if fs := lookupFlagSet(name, c); fs != nil {
57 | if fs := lookupFlagSet(name, c); fs != nil {
58 | isSet := false
59 | fs.Visit(func(f *flag.Flag) {
60 | if f.Name == name {
61 | isSet = true
62 | }
63 | })
64 | if isSet {
65 | return true
66 | }
67 | }
68 |
69 | f := lookupFlag(name, c)
70 | if f == nil {
71 | return false
72 | }
73 |
74 | return f.IsSet()
75 | }
76 |
77 | return false
78 | }
79 |
80 | // LocalFlagNames returns a slice of flag names used in this context.
81 | func (c *Context) LocalFlagNames() []string {
82 | var names []string
83 | c.flagSet.Visit(makeFlagNameVisitor(&names))
84 | return names
85 | }
86 |
87 | // FlagNames returns a slice of flag names used by the this context and all of
88 | // its parent contexts.
89 | func (c *Context) FlagNames() []string {
90 | var names []string
91 | for _, ctx := range c.Lineage() {
92 | ctx.flagSet.Visit(makeFlagNameVisitor(&names))
93 | }
94 | return names
95 | }
96 |
97 | // Lineage returns *this* context and all of its ancestor contexts in order from
98 | // child to parent
99 | func (c *Context) Lineage() []*Context {
100 | var lineage []*Context
101 |
102 | for cur := c; cur != nil; cur = cur.parentContext {
103 | lineage = append(lineage, cur)
104 | }
105 |
106 | return lineage
107 | }
108 |
109 | // Value returns the value of the flag corresponding to `name`
110 | func (c *Context) Value(name string) interface{} {
111 | return c.flagSet.Lookup(name).Value.(flag.Getter).Get()
112 | }
113 |
114 | // Args returns the command line arguments associated with the context.
115 | func (c *Context) Args() Args {
116 | ret := args(c.flagSet.Args())
117 | return &ret
118 | }
119 |
120 | // NArg returns the number of the command line arguments.
121 | func (c *Context) NArg() int {
122 | return c.Args().Len()
123 | }
124 |
125 | func lookupFlag(name string, ctx *Context) Flag {
126 | for _, c := range ctx.Lineage() {
127 | if c.Command == nil {
128 | continue
129 | }
130 |
131 | for _, f := range c.Command.Flags {
132 | for _, n := range f.Names() {
133 | if n == name {
134 | return f
135 | }
136 | }
137 | }
138 | }
139 |
140 | if ctx.App != nil {
141 | for _, f := range ctx.App.Flags {
142 | for _, n := range f.Names() {
143 | if n == name {
144 | return f
145 | }
146 | }
147 | }
148 | }
149 |
150 | return nil
151 | }
152 |
153 | func lookupFlagSet(name string, ctx *Context) *flag.FlagSet {
154 | for _, c := range ctx.Lineage() {
155 | if f := c.flagSet.Lookup(name); f != nil {
156 | return c.flagSet
157 | }
158 | }
159 |
160 | return nil
161 | }
162 |
163 | func copyFlag(name string, ff *flag.Flag, set *flag.FlagSet) {
164 | switch ff.Value.(type) {
165 | case Serializer:
166 | _ = set.Set(name, ff.Value.(Serializer).Serialize())
167 | default:
168 | _ = set.Set(name, ff.Value.String())
169 | }
170 | }
171 |
172 | func normalizeFlags(flags []Flag, set *flag.FlagSet) error {
173 | visited := make(map[string]bool)
174 | set.Visit(func(f *flag.Flag) {
175 | visited[f.Name] = true
176 | })
177 | for _, f := range flags {
178 | parts := f.Names()
179 | if len(parts) == 1 {
180 | continue
181 | }
182 | var ff *flag.Flag
183 | for _, name := range parts {
184 | name = strings.Trim(name, " ")
185 | if visited[name] {
186 | if ff != nil {
187 | return errors.New("Cannot use two forms of the same flag: " + name + " " + ff.Name)
188 | }
189 | ff = set.Lookup(name)
190 | }
191 | }
192 | if ff == nil {
193 | continue
194 | }
195 | for _, name := range parts {
196 | name = strings.Trim(name, " ")
197 | if !visited[name] {
198 | copyFlag(name, ff, set)
199 | }
200 | }
201 | }
202 | return nil
203 | }
204 |
205 | func makeFlagNameVisitor(names *[]string) func(*flag.Flag) {
206 | return func(f *flag.Flag) {
207 | nameParts := strings.Split(f.Name, ",")
208 | name := strings.TrimSpace(nameParts[0])
209 |
210 | for _, part := range nameParts {
211 | part = strings.TrimSpace(part)
212 | if len(part) > len(name) {
213 | name = part
214 | }
215 | }
216 |
217 | if name != "" {
218 | *names = append(*names, name)
219 | }
220 | }
221 | }
222 |
223 | type requiredFlagsErr interface {
224 | error
225 | getMissingFlags() []string
226 | }
227 |
228 | type errRequiredFlags struct {
229 | missingFlags []string
230 | }
231 |
232 | func (e *errRequiredFlags) Error() string {
233 | numberOfMissingFlags := len(e.missingFlags)
234 | if numberOfMissingFlags == 1 {
235 | return fmt.Sprintf("Required flag %q not set", e.missingFlags[0])
236 | }
237 | joinedMissingFlags := strings.Join(e.missingFlags, ", ")
238 | return fmt.Sprintf("Required flags %q not set", joinedMissingFlags)
239 | }
240 |
241 | func (e *errRequiredFlags) getMissingFlags() []string {
242 | return e.missingFlags
243 | }
244 |
245 | func checkRequiredFlags(flags []Flag, context *Context) requiredFlagsErr {
246 | var missingFlags []string
247 | for _, f := range flags {
248 | if rf, ok := f.(RequiredFlag); ok && rf.IsRequired() {
249 | var flagPresent bool
250 | var flagName string
251 |
252 | for _, key := range f.Names() {
253 | if len(key) > 1 {
254 | flagName = key
255 | }
256 |
257 | if context.IsSet(strings.TrimSpace(key)) {
258 | flagPresent = true
259 | }
260 | }
261 |
262 | if !flagPresent && flagName != "" {
263 | missingFlags = append(missingFlags, flagName)
264 | }
265 | }
266 | }
267 |
268 | if len(missingFlags) != 0 {
269 | return &errRequiredFlags{missingFlags: missingFlags}
270 | }
271 |
272 | return nil
273 | }
274 |
--------------------------------------------------------------------------------
/examples/functions/expect.txt:
--------------------------------------------------------------------------------
1 | line 1 started = 2006-01-02 15:04:05.987654321 +0000 UTC
2 | line 2 debugging = true
3 | line 3 debugging = debugging
4 | line 4 debug_toggle = false
5 | line 5 debugging =
6 | line 6 debug = string message
7 | line 7 command_line = testing
8 | line 8 RENDERIZER_VERSION = renderizer
9 | line 9 ip_math = 192.168.0.0
10 | line 10 ip4_inc = 192.168.0.0
11 | line 11 ip4_next = 192.168.0.0
12 | line 12 ip4_prev = 192.168.0.0
13 | line 13 ip_ints = [192 168 0 0]
14 | line 14 ip_ints = 192.168.0.0
15 | line 15 TODO = 0000
16 | line 16 TODO = 0000
17 | line 17 TODO = 0000
18 | line 18 TODO = [0]
19 | line 19 TODO = 0000
20 | line 20 TODO = { {cidr_next} }
21 | line 21 ip_ints = [192 168 0 0]
22 | line 22 ip_split = [1111 2222 3333 4444 5555 6666 7777 8888]
23 | line 23 ip_split = [4369 8738 13107 17476 21845 26214 30583 34952]
24 | line 24 ip_split = [192 168 0 0]
25 | line 25 ip_split = [4369 8738 13107 17476 21845 26214 30583 34952]
26 | line 26 ip_split = 1111.2222.3333.4444.5555.6666.7777.8888
27 | line 27 ip_split = 192.168.0.0
28 | line 28 ip_split = 2222
29 | line 29 ip_split = 8738
30 | line 30 iindex = :
31 | line 31 split = [1111:2222:3333:4444:5555:6666:7777:8888]
32 | line 32 substr = :2222:
33 | line 33 replace = 1111 2222 3333 4444:5555:6666:7777:8888
34 | line 34 replace_ = 1111 2222 3333 4444:5555:6666:7777:8888
35 | line 35 trim = trimmed
36 | line 36 trim_ = trimmed
37 | line 37 trim_left = trimmedxyz
38 | line 38 trim_left_ = trimmedxyz
39 | line 39 trim_right = abctrimmed
40 | line 40 trim_right_ = abctrimmed
41 | line 41 keynext A = 1
42 | line 42 keynext B = 1
43 | line 43 keynext A = 2
44 | line 44 inc = 1 + 5 + 4 = 10
45 | line 45 add = 7 + 3 = 10
46 | line 46 sub = 13 - 3 = 10
47 | line 47 mul = 5 * 2 = 10
48 | line 48 div = 20 / 2 = 10
49 | line 49 mod = 12345 % 10 = 5
50 | line 50 rand = 8717895732742165505
51 | line 51 lower = lower
52 | line 52 upper = UPPER
53 | line 53 title = This Is A Title From Lowercase
54 | line 54 title = THIS IS A TITLE FROM UPPERCASE
55 | line 55 initcap = This Is Initcap From Lowercase
56 | line 56 initcap = This Is Initcap From Uppercase
57 | line 57 cleanser = korsw
58 | line 58 cleanse = [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]
59 | line 59 cleanse = WORKS
60 | line 60 cleanse = WORKS
61 | line 61 cleanse = WORKS
62 | line 62 cleanse = zaqxswcdevfrbgtnhymjukilop
63 |
64 | line 63 dirname = a/b/c
65 | line 64 dirname = /a/b/c
66 | line 65 dirname = .
67 | line 66 dirname = .
68 | line 67 basename = functions
69 | line 68 basename = c
70 | line 69 basename = c.ext
71 | line 70 basename = c
72 | line 71 basename = c.ext.xyz.last
73 | line 72 basename = c.ext.xyz
74 | line 73 basename = c.ext
75 | line 74 basename = c
76 |
77 | line 75 now = 2006-01-02 15:04:05.987654321 +0000 UTC
78 | line 76 pausing 1s = 2006-01-02 15:04:05.987654321 +0000 UTC
79 | line 77 now = 2006-01-02 15:04:05.987654321 +0000 UTC
80 | line 78 started = 2006-01-02 15:04:05.987654321 +0000 UTC
81 |
82 | line 1 started = 2006-01-02 15:04:05.987654321 +0000 UTC
83 | line 2 debugging = true
84 | line 3 debugging = debugging
85 | line 4 debug_toggle = false
86 | line 5 debugging =
87 | line 6 debug = string message
88 | line 7 command_line = testing
89 | line 8 RENDERIZER_VERSION = renderizer
90 | line 9 ip_math = 192.168.0.0
91 | line 10 ip4_inc = 192.168.0.0
92 | line 11 ip4_next = 192.168.0.0
93 | line 12 ip4_prev = 192.168.0.0
94 | line 13 ip_ints = [192 168 0 0]
95 | line 14 ip_ints = 192.168.0.0
96 | line 15 TODO = 0000
97 | line 16 TODO = 0000
98 | line 17 TODO = 0000
99 | line 18 TODO = [0]
100 | line 19 TODO = 0000
101 | line 20 TODO = { {cidr_next} }
102 | line 21 ip_ints = [192 168 0 0]
103 | line 22 ip_split = [1111 2222 3333 4444 5555 6666 7777 8888]
104 | line 23 ip_split = [4369 8738 13107 17476 21845 26214 30583 34952]
105 | line 24 ip_split = [192 168 0 0]
106 | line 25 ip_split = [4369 8738 13107 17476 21845 26214 30583 34952]
107 | line 26 ip_split = 1111.2222.3333.4444.5555.6666.7777.8888
108 | line 27 ip_split = 192.168.0.0
109 | line 28 ip_split = 2222
110 | line 29 ip_split = 8738
111 | line 30 iindex = :
112 | line 31 split = [1111:2222:3333:4444:5555:6666:7777:8888]
113 | line 32 substr = :2222:
114 | line 33 replace = 1111 2222 3333 4444:5555:6666:7777:8888
115 | line 34 replace_ = 1111 2222 3333 4444:5555:6666:7777:8888
116 | line 35 trim = trimmed
117 | line 36 trim_ = trimmed
118 | line 37 trim_left = trimmedxyz
119 | line 38 trim_left_ = trimmedxyz
120 | line 39 trim_right = abctrimmed
121 | line 40 trim_right_ = abctrimmed
122 | line 41 keynext A = 1
123 | line 42 keynext B = 1
124 | line 43 keynext A = 2
125 | line 44 inc = 1 + 5 + 4 = 10
126 | line 45 add = 7 + 3 = 10
127 | line 46 sub = 13 - 3 = 10
128 | line 47 mul = 5 * 2 = 10
129 | line 48 div = 20 / 2 = 10
130 | line 49 mod = 12345 % 10 = 5
131 | line 50 rand = 8717895732742165505
132 | line 51 lower = lower
133 | line 52 upper = UPPER
134 | line 53 title = This Is A Title From Lowercase
135 | line 54 title = THIS IS A TITLE FROM UPPERCASE
136 | line 55 initcap = This Is Initcap From Lowercase
137 | line 56 initcap = This Is Initcap From Uppercase
138 | line 57 cleanser = korsw
139 | line 58 cleanse = [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]
140 | line 59 cleanse = WORKS
141 | line 60 cleanse = WORKS
142 | line 61 cleanse = WORKS
143 | line 62 cleanse = zaqxswcdevfrbgtnhymjukilop
144 |
145 | line 63 dirname = a/b/c
146 | line 64 dirname = /a/b/c
147 | line 65 dirname = .
148 | line 66 dirname = .
149 | line 67 basename = functions
150 | line 68 basename = c
151 | line 69 basename = c.ext
152 | line 70 basename = c
153 | line 71 basename = c.ext.xyz.last
154 | line 72 basename = c.ext.xyz
155 | line 73 basename = c.ext
156 | line 74 basename = c
157 |
158 | line 75 now = 2006-01-02 15:04:05.987654321 +0000 UTC
159 | line 76 pausing 1s = 2006-01-02 15:04:05.987654321 +0000 UTC
160 | line 77 now = 2006-01-02 15:04:05.987654321 +0000 UTC
161 | line 78 started = 2006-01-02 15:04:05.987654321 +0000 UTC
162 |
163 |
--------------------------------------------------------------------------------
/vendor/gopkg.in/yaml.v2/resolve.go:
--------------------------------------------------------------------------------
1 | package yaml
2 |
3 | import (
4 | "encoding/base64"
5 | "math"
6 | "regexp"
7 | "strconv"
8 | "strings"
9 | "time"
10 | )
11 |
12 | type resolveMapItem struct {
13 | value interface{}
14 | tag string
15 | }
16 |
17 | var resolveTable = make([]byte, 256)
18 | var resolveMap = make(map[string]resolveMapItem)
19 |
20 | func init() {
21 | t := resolveTable
22 | t[int('+')] = 'S' // Sign
23 | t[int('-')] = 'S'
24 | for _, c := range "0123456789" {
25 | t[int(c)] = 'D' // Digit
26 | }
27 | for _, c := range "yYnNtTfFoO~" {
28 | t[int(c)] = 'M' // In map
29 | }
30 | t[int('.')] = '.' // Float (potentially in map)
31 |
32 | var resolveMapList = []struct {
33 | v interface{}
34 | tag string
35 | l []string
36 | }{
37 | {true, yaml_BOOL_TAG, []string{"y", "Y", "yes", "Yes", "YES"}},
38 | {true, yaml_BOOL_TAG, []string{"true", "True", "TRUE"}},
39 | {true, yaml_BOOL_TAG, []string{"on", "On", "ON"}},
40 | {false, yaml_BOOL_TAG, []string{"n", "N", "no", "No", "NO"}},
41 | {false, yaml_BOOL_TAG, []string{"false", "False", "FALSE"}},
42 | {false, yaml_BOOL_TAG, []string{"off", "Off", "OFF"}},
43 | {nil, yaml_NULL_TAG, []string{"", "~", "null", "Null", "NULL"}},
44 | {math.NaN(), yaml_FLOAT_TAG, []string{".nan", ".NaN", ".NAN"}},
45 | {math.Inf(+1), yaml_FLOAT_TAG, []string{".inf", ".Inf", ".INF"}},
46 | {math.Inf(+1), yaml_FLOAT_TAG, []string{"+.inf", "+.Inf", "+.INF"}},
47 | {math.Inf(-1), yaml_FLOAT_TAG, []string{"-.inf", "-.Inf", "-.INF"}},
48 | {"<<", yaml_MERGE_TAG, []string{"<<"}},
49 | }
50 |
51 | m := resolveMap
52 | for _, item := range resolveMapList {
53 | for _, s := range item.l {
54 | m[s] = resolveMapItem{item.v, item.tag}
55 | }
56 | }
57 | }
58 |
59 | const longTagPrefix = "tag:yaml.org,2002:"
60 |
61 | func shortTag(tag string) string {
62 | // TODO This can easily be made faster and produce less garbage.
63 | if strings.HasPrefix(tag, longTagPrefix) {
64 | return "!!" + tag[len(longTagPrefix):]
65 | }
66 | return tag
67 | }
68 |
69 | func longTag(tag string) string {
70 | if strings.HasPrefix(tag, "!!") {
71 | return longTagPrefix + tag[2:]
72 | }
73 | return tag
74 | }
75 |
76 | func resolvableTag(tag string) bool {
77 | switch tag {
78 | case "", yaml_STR_TAG, yaml_BOOL_TAG, yaml_INT_TAG, yaml_FLOAT_TAG, yaml_NULL_TAG, yaml_TIMESTAMP_TAG:
79 | return true
80 | }
81 | return false
82 | }
83 |
84 | var yamlStyleFloat = regexp.MustCompile(`^[-+]?(\.[0-9]+|[0-9]+(\.[0-9]*)?)([eE][-+]?[0-9]+)?$`)
85 |
86 | func resolve(tag string, in string) (rtag string, out interface{}) {
87 | if !resolvableTag(tag) {
88 | return tag, in
89 | }
90 |
91 | defer func() {
92 | switch tag {
93 | case "", rtag, yaml_STR_TAG, yaml_BINARY_TAG:
94 | return
95 | case yaml_FLOAT_TAG:
96 | if rtag == yaml_INT_TAG {
97 | switch v := out.(type) {
98 | case int64:
99 | rtag = yaml_FLOAT_TAG
100 | out = float64(v)
101 | return
102 | case int:
103 | rtag = yaml_FLOAT_TAG
104 | out = float64(v)
105 | return
106 | }
107 | }
108 | }
109 | failf("cannot decode %s `%s` as a %s", shortTag(rtag), in, shortTag(tag))
110 | }()
111 |
112 | // Any data is accepted as a !!str or !!binary.
113 | // Otherwise, the prefix is enough of a hint about what it might be.
114 | hint := byte('N')
115 | if in != "" {
116 | hint = resolveTable[in[0]]
117 | }
118 | if hint != 0 && tag != yaml_STR_TAG && tag != yaml_BINARY_TAG {
119 | // Handle things we can lookup in a map.
120 | if item, ok := resolveMap[in]; ok {
121 | return item.tag, item.value
122 | }
123 |
124 | // Base 60 floats are a bad idea, were dropped in YAML 1.2, and
125 | // are purposefully unsupported here. They're still quoted on
126 | // the way out for compatibility with other parser, though.
127 |
128 | switch hint {
129 | case 'M':
130 | // We've already checked the map above.
131 |
132 | case '.':
133 | // Not in the map, so maybe a normal float.
134 | floatv, err := strconv.ParseFloat(in, 64)
135 | if err == nil {
136 | return yaml_FLOAT_TAG, floatv
137 | }
138 |
139 | case 'D', 'S':
140 | // Int, float, or timestamp.
141 | // Only try values as a timestamp if the value is unquoted or there's an explicit
142 | // !!timestamp tag.
143 | if tag == "" || tag == yaml_TIMESTAMP_TAG {
144 | t, ok := parseTimestamp(in)
145 | if ok {
146 | return yaml_TIMESTAMP_TAG, t
147 | }
148 | }
149 |
150 | plain := strings.Replace(in, "_", "", -1)
151 | intv, err := strconv.ParseInt(plain, 0, 64)
152 | if err == nil {
153 | if intv == int64(int(intv)) {
154 | return yaml_INT_TAG, int(intv)
155 | } else {
156 | return yaml_INT_TAG, intv
157 | }
158 | }
159 | uintv, err := strconv.ParseUint(plain, 0, 64)
160 | if err == nil {
161 | return yaml_INT_TAG, uintv
162 | }
163 | if yamlStyleFloat.MatchString(plain) {
164 | floatv, err := strconv.ParseFloat(plain, 64)
165 | if err == nil {
166 | return yaml_FLOAT_TAG, floatv
167 | }
168 | }
169 | if strings.HasPrefix(plain, "0b") {
170 | intv, err := strconv.ParseInt(plain[2:], 2, 64)
171 | if err == nil {
172 | if intv == int64(int(intv)) {
173 | return yaml_INT_TAG, int(intv)
174 | } else {
175 | return yaml_INT_TAG, intv
176 | }
177 | }
178 | uintv, err := strconv.ParseUint(plain[2:], 2, 64)
179 | if err == nil {
180 | return yaml_INT_TAG, uintv
181 | }
182 | } else if strings.HasPrefix(plain, "-0b") {
183 | intv, err := strconv.ParseInt("-" + plain[3:], 2, 64)
184 | if err == nil {
185 | if true || intv == int64(int(intv)) {
186 | return yaml_INT_TAG, int(intv)
187 | } else {
188 | return yaml_INT_TAG, intv
189 | }
190 | }
191 | }
192 | default:
193 | panic("resolveTable item not yet handled: " + string(rune(hint)) + " (with " + in + ")")
194 | }
195 | }
196 | return yaml_STR_TAG, in
197 | }
198 |
199 | // encodeBase64 encodes s as base64 that is broken up into multiple lines
200 | // as appropriate for the resulting length.
201 | func encodeBase64(s string) string {
202 | const lineLen = 70
203 | encLen := base64.StdEncoding.EncodedLen(len(s))
204 | lines := encLen/lineLen + 1
205 | buf := make([]byte, encLen*2+lines)
206 | in := buf[0:encLen]
207 | out := buf[encLen:]
208 | base64.StdEncoding.Encode(in, []byte(s))
209 | k := 0
210 | for i := 0; i < len(in); i += lineLen {
211 | j := i + lineLen
212 | if j > len(in) {
213 | j = len(in)
214 | }
215 | k += copy(out[k:], in[i:j])
216 | if lines > 1 {
217 | out[k] = '\n'
218 | k++
219 | }
220 | }
221 | return string(out[:k])
222 | }
223 |
224 | // This is a subset of the formats allowed by the regular expression
225 | // defined at http://yaml.org/type/timestamp.html.
226 | var allowedTimestampFormats = []string{
227 | "2006-1-2T15:4:5.999999999Z07:00", // RCF3339Nano with short date fields.
228 | "2006-1-2t15:4:5.999999999Z07:00", // RFC3339Nano with short date fields and lower-case "t".
229 | "2006-1-2 15:4:5.999999999", // space separated with no time zone
230 | "2006-1-2", // date only
231 | // Notable exception: time.Parse cannot handle: "2001-12-14 21:59:43.10 -5"
232 | // from the set of examples.
233 | }
234 |
235 | // parseTimestamp parses s as a timestamp string and
236 | // returns the timestamp and reports whether it succeeded.
237 | // Timestamp formats are defined at http://yaml.org/type/timestamp.html
238 | func parseTimestamp(s string) (time.Time, bool) {
239 | // TODO write code to check all the formats supported by
240 | // http://yaml.org/type/timestamp.html instead of using time.Parse.
241 |
242 | // Quick check: all date formats start with YYYY-.
243 | i := 0
244 | for ; i < len(s); i++ {
245 | if c := s[i]; c < '0' || c > '9' {
246 | break
247 | }
248 | }
249 | if i != 4 || i == len(s) || s[i] != '-' {
250 | return time.Time{}, false
251 | }
252 | for _, format := range allowedTimestampFormats {
253 | if t, err := time.Parse(format, s); err == nil {
254 | return t, true
255 | }
256 | }
257 | return time.Time{}, false
258 | }
259 |
--------------------------------------------------------------------------------