diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b32d396..9226af6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,9 +4,8 @@ jobs: test: strategy: matrix: - go-version: [1.13.x, 1.14.x, 1.15.x] - platform: [ubuntu-latest] - runs-on: ${{ matrix.platform }} + go-version: [1.23.x, 1.24.x] + runs-on: ubuntu-latest steps: - name: Install Go uses: actions/setup-go@master diff --git a/Gopkg.lock b/Gopkg.lock deleted file mode 100644 index dfa48c1..0000000 --- a/Gopkg.lock +++ /dev/null @@ -1,49 +0,0 @@ -# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. - - -[[projects]] - digest = "1:6f9339c912bbdda81302633ad7e99a28dfa5a639c864061f1929510a9a64aa74" - name = "github.com/dustin/go-humanize" - packages = ["."] - pruneopts = "UT" - revision = "9f541cc9db5d55bce703bd99987c9d5cb8eea45e" - version = "v1.0.0" - -[[projects]] - digest = "1:7462b19f7e4adb24e966b77213c693dad09c04d58ac8d29ddf449ff1b1c91d11" - name = "github.com/kevinburke/rest" - packages = [ - "restclient", - "resterror", - ] - pruneopts = "UT" - revision = "22cd0577e450f2fa21313f7eaf42b41a178291c1" - version = "2.5" - -[[projects]] - branch = "master" - digest = "1:f2dda646a25cf3b9f6f6931d86ef0b85b64979697e5833cdcbc0c23f2586d996" - name = "github.com/tomnomnom/linkheader" - packages = ["."] - pruneopts = "UT" - revision = "02ca5825eb8097f10d9cc53da78481a85ad84e04" - -[[projects]] - digest = "1:d1d1683ae67edaebf7e51151f934943bf2f53b71260818d843ab7233aa145533" - name = "github.com/voxelbrain/goptions" - packages = ["."] - pruneopts = "UT" - revision = "26cb8b04692384f4dc269de3b5fcf3e2ef78573e" - version = "2.5.11" - -[solve-meta] - analyzer-name = "dep" - analyzer-version = 1 - input-imports = [ - "github.com/dustin/go-humanize", - "github.com/kevinburke/rest/restclient", - "github.com/tomnomnom/linkheader", - "github.com/voxelbrain/goptions", - ] - solver-name = "gps-cdcl" - solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml deleted file mode 100644 index e01d239..0000000 --- a/Gopkg.toml +++ /dev/null @@ -1,24 +0,0 @@ -# Gopkg.toml example -# -# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html -# for detailed Gopkg.toml documentation. - -[[constraint]] - name = "github.com/dustin/go-humanize" - version = "1.0.0" - -[[constraint]] - name = "github.com/kevinburke/rest" - version = "2.5.0" - -[[constraint]] - name = "github.com/tomnomnom/linkheader" - branch = "master" - -[[constraint]] - name = "github.com/voxelbrain/goptions" - version = "2.5.11" - -[prune] - go-tests = true - unused-packages = true diff --git a/Makefile b/Makefile index 3085ed7..87f6565 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ SHELL=/bin/bash -o pipefail -LAST_TAG := $(shell git describe --abbrev=0 --tags) +LAST_TAG ?= $(shell git describe --abbrev=0 --tags) USER := github-release EXECUTABLE := github-release @@ -64,9 +64,10 @@ ifndef GITHUB_TOKEN endif docker run --rm --volume $(PWD)/var/cache:/root/.cache/go-build \ --env GITHUB_TOKEN=$(GITHUB_TOKEN) \ - --volume "$(PWD)":/go/src/github.com/github-release/github-release \ - --workdir /go/src/github.com/github-release/github-release \ - meterup/ubuntu-golang:latest \ + --env DEBUG_HTTP_TRAFFIC=true \ + --volume "$(PWD)":/app \ + --workdir /app \ + golang:latest \ ./release \ "$(MAKE) bin/tmp/$(EXECUTABLE) $(COMPRESSED_EXECUTABLE_TARGETS) && \ git log --format=%B $(LAST_TAG) -1 | \ @@ -74,13 +75,7 @@ endif -t $(LAST_TAG) -n $(LAST_TAG) -d - || true && \ $(foreach FILE,$(COMPRESSED_EXECUTABLES),$(UPLOAD_CMD);)" -# install and/or update all dependencies, run this from the project directory -# go get -u ./... -# go test -i ./ -dep: - go list -f '{{join .Deps "\n"}}' | xargs go list -e -f '{{if not .Standard}}{{.ImportPath}}{{end}}' | xargs go get -u - -$(EXECUTABLE): dep +$(EXECUTABLE): go build -o "$@" install: @@ -97,4 +92,4 @@ lint: test: go test ./... -.PHONY: clean release dep install +.PHONY: clean release install diff --git a/README.md b/README.md index b2f3b34..a9eba6a 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ dogfooding, check the makefile! If you have Go installed, you can just do: ```sh -go get github.com/github-release/github-release +go install github.com/github-release/github-release ``` This will automatically download, compile and install the app. diff --git a/cmd.go b/cmd.go index 294fdac..506ab28 100644 --- a/cmd.go +++ b/cmd.go @@ -317,11 +317,16 @@ func releasecmd(opt Options) error { repo := nvls(cmdopt.Repo, EnvRepo) token := nvls(cmdopt.Token, EnvToken) tag := cmdopt.Tag - name := nvls(cmdopt.Name, tag) - desc := nvls(cmdopt.Desc, tag) + name := cmdopt.Name + desc := cmdopt.Desc target := nvls(cmdopt.Target) draft := cmdopt.Draft prerelease := cmdopt.Prerelease + generateReleaseNotes := cmdopt.GenerateReleaseNotes + if !generateReleaseNotes { + name = nvls(name, tag) + desc = nvls(desc, tag) + } vprintln("releasing...") @@ -339,12 +344,13 @@ func releasecmd(opt Options) error { } params := ReleaseCreate{ - TagName: tag, - TargetCommitish: target, - Name: name, - Body: desc, - Draft: draft, - Prerelease: prerelease, + TagName: tag, + TargetCommitish: target, + Name: name, + Body: desc, + Draft: draft, + Prerelease: prerelease, + GenerateReleaseNotes: generateReleaseNotes, } /* encode params as json */ diff --git a/github-release.go b/github-release.go index 28be5a1..5303cb8 100644 --- a/github-release.go +++ b/github-release.go @@ -38,15 +38,16 @@ type Options struct { Replace bool `goptions:"-R, --replace, description='Replace asset with same name if it already exists (WARNING: not atomic, failure to upload will remove the original asset too)'"` } `goptions:"upload"` Release struct { - Token string `goptions:"-s, --security-token, description='Github token (required if $GITHUB_TOKEN not set)'"` - User string `goptions:"-u, --user, description='Github repo user or organisation (required if $GITHUB_USER not set)'"` - Repo string `goptions:"-r, --repo, description='Github repo (required if $GITHUB_REPO not set)'"` - Tag string `goptions:"-t, --tag, obligatory, description='Git tag to create a release from'"` - Name string `goptions:"-n, --name, description='Name of the release (defaults to tag)'"` - Desc string `goptions:"-d, --description, description='Release description, use - for reading a description from stdin (defaults to tag)'"` - Target string `goptions:"-c, --target, description='Commit SHA or branch to create release of (defaults to the repository default branch)'"` - Draft bool `goptions:"--draft, description='The release is a draft'"` - Prerelease bool `goptions:"-p, --pre-release, description='The release is a pre-release'"` + Token string `goptions:"-s, --security-token, description='Github token (required if $GITHUB_TOKEN not set)'"` + User string `goptions:"-u, --user, description='Github repo user or organisation (required if $GITHUB_USER not set)'"` + Repo string `goptions:"-r, --repo, description='Github repo (required if $GITHUB_REPO not set)'"` + Tag string `goptions:"-t, --tag, obligatory, description='Git tag to create a release from'"` + Name string `goptions:"-n, --name, description='Name of the release (defaults to tag)'"` + Desc string `goptions:"-d, --description, description='Release description, use - for reading a description from stdin (defaults to tag)'"` + Target string `goptions:"-c, --target, description='Commit SHA or branch to create release of (defaults to the repository default branch)'"` + Draft bool `goptions:"--draft, description='The release is a draft'"` + Prerelease bool `goptions:"-p, --pre-release, description='The release is a pre-release'"` + GenerateReleaseNotes bool `goptions:"-g, --generate-release-notes, description='Generate name and description if not given'"` } `goptions:"release"` Edit struct { Token string `goptions:"-s, --security-token, description='Github token (required if $GITHUB_TOKEN not set)'"` diff --git a/github/version.go b/github/version.go index 46e4088..7c86c5e 100644 --- a/github/version.go +++ b/github/version.go @@ -1,3 +1,3 @@ package github -const VERSION = "0.10.0" +const VERSION = "0.11.0" diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..27d2c9a --- /dev/null +++ b/go.mod @@ -0,0 +1,10 @@ +module github.com/github-release/github-release + +go 1.23.0 + +require ( + github.com/dustin/go-humanize v1.0.1 + github.com/kevinburke/rest v0.0.0-20250718180114-1a15e4f2364f + github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80 + github.com/voxelbrain/goptions v0.0.0-20180630082107-58cddc247ea2 +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..874fb47 --- /dev/null +++ b/go.sum @@ -0,0 +1,8 @@ +github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= +github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= +github.com/kevinburke/rest v0.0.0-20250718180114-1a15e4f2364f h1:y+inhBsY0ewgXFXCXlxodNxkXdYeU9YuneCYQEnRkmw= +github.com/kevinburke/rest v0.0.0-20250718180114-1a15e4f2364f/go.mod h1:3cBF15uOiTj025Ll5QHLw317EB+e06+AEwyt7oHUubI= +github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80 h1:nrZ3ySNYwJbSpD6ce9duiP+QkD3JuLCcWkdaehUS/3Y= +github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80/go.mod h1:iFyPdL66DjUD96XmzVL3ZntbzcflLnznH0fr99w5VqE= +github.com/voxelbrain/goptions v0.0.0-20180630082107-58cddc247ea2 h1:txplJASvd6b/hrE0s/Ixfpp2cuwH9IO9oZBAN9iYa4A= +github.com/voxelbrain/goptions v0.0.0-20180630082107-58cddc247ea2/go.mod h1:DGCIhurYgnLz8J9ga1fMV/fbLDyUvTyrWXVWUIyJon4= diff --git a/release b/release index 3557211..4a1f30e 100755 --- a/release +++ b/release @@ -3,7 +3,7 @@ set -euo pipefail main() { - apt-get update && apt-get install zip + apt-get update && apt-get install -y zip bzip2 git branch --set-upstream-to=origin/master release set -x exec /bin/bash -c "$@" diff --git a/releases.go b/releases.go index 83d4f02..05177a3 100644 --- a/releases.go +++ b/releases.go @@ -59,12 +59,13 @@ func (r *Release) String() string { } type ReleaseCreate struct { - TagName string `json:"tag_name"` - TargetCommitish string `json:"target_commitish,omitempty"` - Name string `json:"name"` - Body string `json:"body"` - Draft bool `json:"draft"` - Prerelease bool `json:"prerelease"` + TagName string `json:"tag_name"` + TargetCommitish string `json:"target_commitish,omitempty"` + Name string `json:"name"` + Body string `json:"body"` + Draft bool `json:"draft"` + Prerelease bool `json:"prerelease"` + GenerateReleaseNotes bool `json:"generate_release_notes"` } func Releases(user, repo, authUser, token string) ([]Release, error) { diff --git a/vendor/github.com/dustin/go-humanize/.travis.yml b/vendor/github.com/dustin/go-humanize/.travis.yml index ba95cdd..ac12e48 100644 --- a/vendor/github.com/dustin/go-humanize/.travis.yml +++ b/vendor/github.com/dustin/go-humanize/.travis.yml @@ -1,12 +1,12 @@ sudo: false language: go +go_import_path: github.com/dustin/go-humanize go: - - 1.3.x - - 1.5.x - - 1.6.x - - 1.7.x - - 1.8.x - - 1.9.x + - 1.13.x + - 1.14.x + - 1.15.x + - 1.16.x + - stable - master matrix: allow_failures: @@ -15,7 +15,7 @@ matrix: install: - # 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). script: - - go get -t -v ./... - diff -u <(echo -n) <(gofmt -d -s .) - - go tool vet . + - go vet . + - go install -v -race ./... - go test -v -race ./... diff --git a/vendor/github.com/dustin/go-humanize/README.markdown b/vendor/github.com/dustin/go-humanize/README.markdown index 91b4ae5..7d0b16b 100644 --- a/vendor/github.com/dustin/go-humanize/README.markdown +++ b/vendor/github.com/dustin/go-humanize/README.markdown @@ -5,7 +5,7 @@ Just a few functions for helping humanize times and sizes. `go get` it as `github.com/dustin/go-humanize`, import it as `"github.com/dustin/go-humanize"`, use it as `humanize`. -See [godoc](https://godoc.org/github.com/dustin/go-humanize) for +See [godoc](https://pkg.go.dev/github.com/dustin/go-humanize) for complete documentation. ## Sizes diff --git a/vendor/github.com/dustin/go-humanize/bigbytes.go b/vendor/github.com/dustin/go-humanize/bigbytes.go index 1a2bf61..3b015fd 100644 --- a/vendor/github.com/dustin/go-humanize/bigbytes.go +++ b/vendor/github.com/dustin/go-humanize/bigbytes.go @@ -28,6 +28,10 @@ var ( BigZiByte = (&big.Int{}).Mul(BigEiByte, bigIECExp) // BigYiByte is 1,024 z bytes in bit.Ints BigYiByte = (&big.Int{}).Mul(BigZiByte, bigIECExp) + // BigRiByte is 1,024 y bytes in bit.Ints + BigRiByte = (&big.Int{}).Mul(BigYiByte, bigIECExp) + // BigQiByte is 1,024 r bytes in bit.Ints + BigQiByte = (&big.Int{}).Mul(BigRiByte, bigIECExp) ) var ( @@ -51,6 +55,10 @@ var ( BigZByte = (&big.Int{}).Mul(BigEByte, bigSIExp) // BigYByte is 1,000 SI z bytes in big.Ints BigYByte = (&big.Int{}).Mul(BigZByte, bigSIExp) + // BigRByte is 1,000 SI y bytes in big.Ints + BigRByte = (&big.Int{}).Mul(BigYByte, bigSIExp) + // BigQByte is 1,000 SI r bytes in big.Ints + BigQByte = (&big.Int{}).Mul(BigRByte, bigSIExp) ) var bigBytesSizeTable = map[string]*big.Int{ @@ -71,6 +79,10 @@ var bigBytesSizeTable = map[string]*big.Int{ "zb": BigZByte, "yib": BigYiByte, "yb": BigYByte, + "rib": BigRiByte, + "rb": BigRByte, + "qib": BigQiByte, + "qb": BigQByte, // Without suffix "": BigByte, "ki": BigKiByte, @@ -89,6 +101,10 @@ var bigBytesSizeTable = map[string]*big.Int{ "zi": BigZiByte, "y": BigYByte, "yi": BigYiByte, + "r": BigRByte, + "ri": BigRiByte, + "q": BigQByte, + "qi": BigQiByte, } var ten = big.NewInt(10) @@ -115,7 +131,7 @@ func humanateBigBytes(s, base *big.Int, sizes []string) string { // // BigBytes(82854982) -> 83 MB func BigBytes(s *big.Int) string { - sizes := []string{"B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"} + sizes := []string{"B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB", "RB", "QB"} return humanateBigBytes(s, bigSIExp, sizes) } @@ -125,7 +141,7 @@ func BigBytes(s *big.Int) string { // // BigIBytes(82854982) -> 79 MiB func BigIBytes(s *big.Int) string { - sizes := []string{"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"} + sizes := []string{"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB", "RiB", "QiB"} return humanateBigBytes(s, bigIECExp, sizes) } diff --git a/vendor/github.com/dustin/go-humanize/commaf.go b/vendor/github.com/dustin/go-humanize/commaf.go index 620690d..2bc83a0 100644 --- a/vendor/github.com/dustin/go-humanize/commaf.go +++ b/vendor/github.com/dustin/go-humanize/commaf.go @@ -1,3 +1,4 @@ +//go:build go1.6 // +build go1.6 package humanize diff --git a/vendor/github.com/dustin/go-humanize/ftoa.go b/vendor/github.com/dustin/go-humanize/ftoa.go index 1c62b64..bce923f 100644 --- a/vendor/github.com/dustin/go-humanize/ftoa.go +++ b/vendor/github.com/dustin/go-humanize/ftoa.go @@ -6,6 +6,9 @@ import ( ) func stripTrailingZeros(s string) string { + if !strings.ContainsRune(s, '.') { + return s + } offset := len(s) - 1 for offset > 0 { if s[offset] == '.' { diff --git a/vendor/github.com/dustin/go-humanize/number.go b/vendor/github.com/dustin/go-humanize/number.go index dec6186..6470d0d 100644 --- a/vendor/github.com/dustin/go-humanize/number.go +++ b/vendor/github.com/dustin/go-humanize/number.go @@ -73,7 +73,7 @@ func FormatFloat(format string, n float64) string { if n > math.MaxFloat64 { return "Infinity" } - if n < -math.MaxFloat64 { + if n < (0.0 - math.MaxFloat64) { return "-Infinity" } diff --git a/vendor/github.com/dustin/go-humanize/si.go b/vendor/github.com/dustin/go-humanize/si.go index ae659e0..8b85019 100644 --- a/vendor/github.com/dustin/go-humanize/si.go +++ b/vendor/github.com/dustin/go-humanize/si.go @@ -8,6 +8,8 @@ import ( ) var siPrefixTable = map[float64]string{ + -30: "q", // quecto + -27: "r", // ronto -24: "y", // yocto -21: "z", // zepto -18: "a", // atto @@ -25,6 +27,8 @@ var siPrefixTable = map[float64]string{ 18: "E", // exa 21: "Z", // zetta 24: "Y", // yotta + 27: "R", // ronna + 30: "Q", // quetta } var revSIPrefixTable = revfmap(siPrefixTable) diff --git a/vendor/github.com/kevinburke/rest/restclient/client.go b/vendor/github.com/kevinburke/rest/restclient/client.go index 7405b02..ca88014 100644 --- a/vendor/github.com/kevinburke/rest/restclient/client.go +++ b/vendor/github.com/kevinburke/rest/restclient/client.go @@ -5,11 +5,11 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net" "net/http" "runtime" "strings" + "sync/atomic" "time" "github.com/kevinburke/rest/resterror" @@ -23,7 +23,7 @@ var JSON UploadType = "application/json" // FormURLEncoded specifies you'd like to upload form-urlencoded data. var FormURLEncoded UploadType = "application/x-www-form-urlencoded" -const Version = "2.5" +const Version = "2.12.0" var ua string @@ -37,8 +37,6 @@ func init() { type Client struct { // Username for use in HTTP Basic Auth ID string - // Password for use in HTTP Basic Auth - Token string // HTTP Client to use for making requests Client *http.Client // The base URL for all requests to this API, for example, @@ -52,32 +50,48 @@ type Client struct { ErrorParser func(*http.Response) error useBearerAuth bool + + // Password for use in HTTP Basic Auth, or single token in Bearer auth + token atomic.Value +} + +func (c *Client) Token() string { + l := c.token.Load() + s, _ := l.(string) + return s } // New returns a new Client with HTTP Basic Auth with the given user and // password. Base is the scheme+domain to hit for all requests. func New(user, pass, base string) *Client { - return &Client{ + + c := &Client{ ID: user, - Token: pass, Client: defaultHttpClient, Base: base, UploadType: JSON, ErrorParser: DefaultErrorParser, } + c.token.Store(pass) + return c } // NewBearerClient returns a new Client configured to use Bearer authentication. func NewBearerClient(token, base string) *Client { - return &Client{ + c := &Client{ ID: "", - Token: token, Client: defaultHttpClient, Base: base, UploadType: JSON, ErrorParser: DefaultErrorParser, useBearerAuth: true, } + c.token.Store(token) + return c +} + +func (c *Client) UpdateToken(newToken string) { + c.token.Store(newToken) } var defaultDialer = &net.Dialer{ @@ -127,21 +141,23 @@ func (c *Client) DialSocket(socket string, transport *http.Transport) { } } -// NewRequest creates a new Request and sets basic auth based on the client's -// authentication information. -func (c *Client) NewRequest(method, path string, body io.Reader) (*http.Request, error) { +func (c *Client) NewRequestWithContext(ctx context.Context, method, path string, body io.Reader) (*http.Request, error) { + if c == nil { + panic("cannot call NewRequestWithContext on nil *Client") + } // see for example https://github.com/meterup/github-release/issues/1 - if // the path contains the full URL including the base, strip it out path = strings.TrimPrefix(path, c.Base) - req, err := http.NewRequest(method, c.Base+path, body) + req, err := http.NewRequestWithContext(ctx, method, c.Base+path, body) if err != nil { return nil, err } + token := c.Token() switch { - case c.useBearerAuth && c.Token != "": - req.Header.Add("Authorization", "Bearer "+c.Token) - case !c.useBearerAuth && (c.ID != "" || c.Token != ""): - req.SetBasicAuth(c.ID, c.Token) + case c.useBearerAuth && token != "": + req.Header.Add("Authorization", "Bearer "+token) + case !c.useBearerAuth && (c.ID != "" || token != ""): + req.SetBasicAuth(c.ID, token) } req.Header.Add("User-Agent", ua) req.Header.Add("Accept", "application/json") @@ -151,11 +167,17 @@ func (c *Client) NewRequest(method, path string, body io.Reader) (*http.Request, if uploadType == "" { uploadType = JSON } - req.Header.Add("Content-Type", fmt.Sprintf("%s; charset=utf-8", uploadType)) + req.Header.Add("Content-Type", string(uploadType)+"; charset=utf-8") } return req, nil } +// NewRequest creates a new Request and sets basic auth based on the client's +// authentication information. +func (c *Client) NewRequest(method, path string, body io.Reader) (*http.Request, error) { + return c.NewRequestWithContext(context.Background(), method, path, body) +} + // Do performs the HTTP request. If the HTTP response is in the 2xx range, // Unmarshal the response body into v. If the response status code is 400 or // above, attempt to Unmarshal the response into an Error. Otherwise return @@ -179,7 +201,7 @@ func (c *Client) Do(r *http.Request, v interface{}) error { return DefaultErrorParser(res) } - resBody, err := ioutil.ReadAll(res.Body) + resBody, err := io.ReadAll(res.Body) if err != nil { return err } @@ -193,7 +215,7 @@ func (c *Client) Do(r *http.Request, v interface{}) error { // DefaultErrorParser attempts to parse the response body as a rest.Error. If // it cannot do so, return an error containing the entire response body. func DefaultErrorParser(resp *http.Response) error { - resBody, err := ioutil.ReadAll(resp.Body) + resBody, err := io.ReadAll(resp.Body) if err != nil { return err } diff --git a/vendor/github.com/voxelbrain/goptions/circle.yml b/vendor/github.com/voxelbrain/goptions/circle.yml index 33753cd..b399d44 100644 --- a/vendor/github.com/voxelbrain/goptions/circle.yml +++ b/vendor/github.com/voxelbrain/goptions/circle.yml @@ -1,4 +1,9 @@ -test: - override: - - go list -f "{{range .TestImports}}{{.}} {{end}}" . | xargs -r go get - - go test +version: 2 +jobs: + build: + docker: + - image: circleci/golang + steps: + - checkout + - run: go get -d . + - run: go test diff --git a/vendor/github.com/voxelbrain/goptions/options.go b/vendor/github.com/voxelbrain/goptions/options.go index 283ae36..86ed6bc 100644 --- a/vendor/github.com/voxelbrain/goptions/options.go +++ b/vendor/github.com/voxelbrain/goptions/options.go @@ -6,6 +6,7 @@ import ( "reflect" "strconv" "strings" + "time" ) type optionFunc func(f *Flag, option, value string) error @@ -19,6 +20,9 @@ var ( "obligatory": obligatory, "mutexgroup": mutexgroup, }, + reflect.TypeOf(new(time.Time)).Elem(): optionMap{ + "format": time_format, + }, reflect.TypeOf(new(*os.File)).Elem(): optionMap{ "create": initOptionMeta(file_create, "file_mode", 0), "append": initOptionMeta(file_append, "file_mode", 0), @@ -113,6 +117,11 @@ func file_perm(f *Flag, option, value string) error { return nil } +func time_format(f *Flag, option, value string) error { + f.optionMeta["format"] = value + return nil +} + func optionMapForType(t reflect.Type) optionMap { g := typeOptionMap[nil] m, _ := typeOptionMap[t] diff --git a/vendor/github.com/voxelbrain/goptions/valueparser.go b/vendor/github.com/voxelbrain/goptions/valueparser.go index 7a77c2a..e8176fa 100644 --- a/vendor/github.com/voxelbrain/goptions/valueparser.go +++ b/vendor/github.com/voxelbrain/goptions/valueparser.go @@ -26,6 +26,7 @@ var ( reflect.TypeOf(new(*net.TCPAddr)).Elem(): tcpAddrValueParser, reflect.TypeOf(new(*url.URL)).Elem(): urlValueParser, reflect.TypeOf(new(time.Duration)).Elem(): durationValueParser, + reflect.TypeOf(new(time.Time)).Elem(): timeValueParser, } ) @@ -148,6 +149,15 @@ func durationValueParser(f *Flag, val string) (reflect.Value, error) { return reflect.ValueOf(d), err } +func timeValueParser(f *Flag, val string) (reflect.Value, error) { + format := time.RFC3339 + if altFormat, ok := f.optionMeta["format"]; ok { + format = altFormat.(string) + } + d, err := time.Parse(format, val) + return reflect.ValueOf(d), err +} + func helpValueParser(f *Flag, val string) (reflect.Value, error) { return reflect.Value{}, ErrHelpRequest } diff --git a/vendor/modules.txt b/vendor/modules.txt new file mode 100644 index 0000000..2ecbcc9 --- /dev/null +++ b/vendor/modules.txt @@ -0,0 +1,13 @@ +# github.com/dustin/go-humanize v1.0.1 +## explicit; go 1.16 +github.com/dustin/go-humanize +# github.com/kevinburke/rest v0.0.0-20250718180114-1a15e4f2364f +## explicit; go 1.23.0 +github.com/kevinburke/rest/restclient +github.com/kevinburke/rest/resterror +# github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80 +## explicit +github.com/tomnomnom/linkheader +# github.com/voxelbrain/goptions v0.0.0-20180630082107-58cddc247ea2 +## explicit +github.com/voxelbrain/goptions