diff --git a/.gitignore b/.gitignore index df5cc5f0..99543ebb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,5 @@ bin/ benchmark/ -.vendor/pkg -servertest -.vendor/src/github.com/github/git-lfs # only allow man/*.\d.ronn files man/* diff --git a/Godeps b/Godeps deleted file mode 100644 index 5fd6349c..00000000 --- a/Godeps +++ /dev/null @@ -1,9 +0,0 @@ -github.com/bmizerany/assert e17e99893cb6509f428e1728281c2ad60a6b31e3 -github.com/cheggaaa/pb bd14546a551971ae7f460e6d6e527c5b56cd38d7 -github.com/kr/pretty 088c856450c08c03eb32f7a6c221e6eefaa10e6f -github.com/kr/text 6807e777504f54ad073ecef66747de158294b639 -github.com/olekukonko/ts ecf753e7c962639ab5a1fb46f7da627d4c0a04b8 -github.com/spf13/cobra 864687ae689edc28688c67edef47e3d2ad651a1b -github.com/spf13/pflag 463bdc838f2b35e9307e91d480878bda5fff7232 -github.com/technoweenie/go-contentaddressable 38171def3cd15e3b76eb156219b3d48704643899 -github.com/rubyist/tracerx 51cd50e73e07cc41c22caec66af15313dff1aebb diff --git a/Nut.toml b/Nut.toml new file mode 100644 index 00000000..a03b8dda --- /dev/null +++ b/Nut.toml @@ -0,0 +1,21 @@ +[application] + +name = "git-lfs" +version = "0.5.1" +authors = [ + "Rick Olson ", + "Scott Barron ", +] + +[dependencies] + +"github.com/cheggaaa/pb" = "bd14546a551971ae7f460e6d6e527c5b56cd38d7" +"github.com/kr/pretty" = "088c856450c08c03eb32f7a6c221e6eefaa10e6f" +"github.com/kr/pty" = "5cf931ef8f76dccd0910001d74a58a7fca84a83d" +"github.com/kr/text" = "6807e777504f54ad073ecef66747de158294b639" +"github.com/olekukonko/ts" = "ecf753e7c962639ab5a1fb46f7da627d4c0a04b8" +"github.com/rubyist/tracerx" = "51cd50e73e07cc41c22caec66af15313dff1aebb" +"github.com/spf13/cobra" = "864687ae689edc28688c67edef47e3d2ad651a1b" +"github.com/spf13/pflag" = "463bdc838f2b35e9307e91d480878bda5fff7232" +"github.com/technoweenie/assert" = "b25ea301d127043ffacf3b2545726e79b6632139" +"github.com/technoweenie/go-contentaddressable" = "38171def3cd15e3b76eb156219b3d48704643899" diff --git a/commands/command_clean.go b/commands/command_clean.go index fc176e75..7da22c0a 100644 --- a/commands/command_clean.go +++ b/commands/command_clean.go @@ -4,7 +4,7 @@ import ( "os" "github.com/github/git-lfs/lfs" - "github.com/spf13/cobra" + "github.com/github/git-lfs/vendor/_nuts/github.com/spf13/cobra" ) var ( diff --git a/commands/command_env.go b/commands/command_env.go index 459449e1..8cfb0300 100644 --- a/commands/command_env.go +++ b/commands/command_env.go @@ -2,7 +2,7 @@ package commands import ( "github.com/github/git-lfs/lfs" - "github.com/spf13/cobra" + "github.com/github/git-lfs/vendor/_nuts/github.com/spf13/cobra" ) var ( diff --git a/commands/command_get.go b/commands/command_get.go index 2cb8ab1c..4e49078d 100644 --- a/commands/command_get.go +++ b/commands/command_get.go @@ -7,8 +7,8 @@ import ( "github.com/github/git-lfs/git" "github.com/github/git-lfs/lfs" - "github.com/rubyist/tracerx" - "github.com/spf13/cobra" + "github.com/github/git-lfs/vendor/_nuts/github.com/rubyist/tracerx" + "github.com/github/git-lfs/vendor/_nuts/github.com/spf13/cobra" ) var ( diff --git a/commands/command_init.go b/commands/command_init.go index 9e89ef45..bf1bba3a 100644 --- a/commands/command_init.go +++ b/commands/command_init.go @@ -2,7 +2,7 @@ package commands import ( "github.com/github/git-lfs/lfs" - "github.com/spf13/cobra" + "github.com/github/git-lfs/vendor/_nuts/github.com/spf13/cobra" ) var ( diff --git a/commands/command_logs.go b/commands/command_logs.go index 46209d41..53da90db 100644 --- a/commands/command_logs.go +++ b/commands/command_logs.go @@ -7,7 +7,7 @@ import ( "path/filepath" "github.com/github/git-lfs/lfs" - "github.com/spf13/cobra" + "github.com/github/git-lfs/vendor/_nuts/github.com/spf13/cobra" ) var ( diff --git a/commands/command_ls_files.go b/commands/command_ls_files.go index a9d03237..5b5febef 100644 --- a/commands/command_ls_files.go +++ b/commands/command_ls_files.go @@ -3,7 +3,7 @@ package commands import ( "github.com/github/git-lfs/git" "github.com/github/git-lfs/lfs" - "github.com/spf13/cobra" + "github.com/github/git-lfs/vendor/_nuts/github.com/spf13/cobra" ) var ( diff --git a/commands/command_pointer.go b/commands/command_pointer.go index 6211e44c..b4905a12 100644 --- a/commands/command_pointer.go +++ b/commands/command_pointer.go @@ -11,7 +11,7 @@ import ( "os/exec" "github.com/github/git-lfs/lfs" - "github.com/spf13/cobra" + "github.com/github/git-lfs/vendor/_nuts/github.com/spf13/cobra" ) var ( diff --git a/commands/command_pre_push.go b/commands/command_pre_push.go index 128c5cb5..e878b148 100644 --- a/commands/command_pre_push.go +++ b/commands/command_pre_push.go @@ -6,7 +6,7 @@ import ( "strings" "github.com/github/git-lfs/lfs" - "github.com/spf13/cobra" + "github.com/github/git-lfs/vendor/_nuts/github.com/spf13/cobra" ) var ( diff --git a/commands/command_push.go b/commands/command_push.go index 66fd36aa..adf638f1 100644 --- a/commands/command_push.go +++ b/commands/command_push.go @@ -7,8 +7,8 @@ import ( "github.com/github/git-lfs/git" "github.com/github/git-lfs/lfs" - "github.com/rubyist/tracerx" - "github.com/spf13/cobra" + "github.com/github/git-lfs/vendor/_nuts/github.com/rubyist/tracerx" + "github.com/github/git-lfs/vendor/_nuts/github.com/spf13/cobra" ) var ( diff --git a/commands/command_smudge.go b/commands/command_smudge.go index bcd82ca1..99543b0f 100644 --- a/commands/command_smudge.go +++ b/commands/command_smudge.go @@ -7,7 +7,7 @@ import ( "path/filepath" "github.com/github/git-lfs/lfs" - "github.com/spf13/cobra" + "github.com/github/git-lfs/vendor/_nuts/github.com/spf13/cobra" ) var ( diff --git a/commands/command_status.go b/commands/command_status.go index 4f4ea066..6ba316e8 100644 --- a/commands/command_status.go +++ b/commands/command_status.go @@ -5,7 +5,7 @@ import ( "github.com/github/git-lfs/git" "github.com/github/git-lfs/lfs" - "github.com/spf13/cobra" + "github.com/github/git-lfs/vendor/_nuts/github.com/spf13/cobra" ) var ( diff --git a/commands/command_track.go b/commands/command_track.go index 2120cb2c..53d6c432 100644 --- a/commands/command_track.go +++ b/commands/command_track.go @@ -9,7 +9,7 @@ import ( "strings" "github.com/github/git-lfs/lfs" - "github.com/spf13/cobra" + "github.com/github/git-lfs/vendor/_nuts/github.com/spf13/cobra" ) var ( diff --git a/commands/command_untrack.go b/commands/command_untrack.go index f2ebc480..ca5e2630 100644 --- a/commands/command_untrack.go +++ b/commands/command_untrack.go @@ -7,7 +7,7 @@ import ( "strings" "github.com/github/git-lfs/lfs" - "github.com/spf13/cobra" + "github.com/github/git-lfs/vendor/_nuts/github.com/spf13/cobra" ) var ( diff --git a/commands/command_update.go b/commands/command_update.go index d554ae5c..fdfba5f6 100644 --- a/commands/command_update.go +++ b/commands/command_update.go @@ -2,7 +2,7 @@ package commands import ( "github.com/github/git-lfs/lfs" - "github.com/spf13/cobra" + "github.com/github/git-lfs/vendor/_nuts/github.com/spf13/cobra" ) var ( diff --git a/commands/command_version.go b/commands/command_version.go index 309aa386..f0b18fdc 100644 --- a/commands/command_version.go +++ b/commands/command_version.go @@ -2,7 +2,7 @@ package commands import ( "github.com/github/git-lfs/lfs" - "github.com/spf13/cobra" + "github.com/github/git-lfs/vendor/_nuts/github.com/spf13/cobra" ) var ( diff --git a/commands/commands.go b/commands/commands.go index aaefec3f..2688c67b 100644 --- a/commands/commands.go +++ b/commands/commands.go @@ -12,7 +12,7 @@ import ( "time" "github.com/github/git-lfs/lfs" - "github.com/spf13/cobra" + "github.com/github/git-lfs/vendor/_nuts/github.com/spf13/cobra" ) var ( diff --git a/cmd/git-lfs/git-lfs.go b/git-lfs.go similarity index 100% rename from cmd/git-lfs/git-lfs.go rename to git-lfs.go diff --git a/git/git.go b/git/git.go index 77f31fa2..575b1ec3 100644 --- a/git/git.go +++ b/git/git.go @@ -8,7 +8,7 @@ import ( "os/exec" "strings" - "github.com/rubyist/tracerx" + "github.com/github/git-lfs/vendor/_nuts/github.com/rubyist/tracerx" ) func LsRemote(remote, remoteRef string) (string, error) { diff --git a/lfs/client.go b/lfs/client.go index e7ab7454..30c177de 100644 --- a/lfs/client.go +++ b/lfs/client.go @@ -14,7 +14,7 @@ import ( "regexp" "strconv" - "github.com/rubyist/tracerx" + "github.com/github/git-lfs/vendor/_nuts/github.com/rubyist/tracerx" ) const ( diff --git a/lfs/config_test.go b/lfs/config_test.go index 1508f72d..cd232971 100644 --- a/lfs/config_test.go +++ b/lfs/config_test.go @@ -3,7 +3,7 @@ package lfs import ( "testing" - "github.com/bmizerany/assert" + "github.com/github/git-lfs/vendor/_nuts/github.com/technoweenie/assert" ) func TestEndpointDefaultsToOrigin(t *testing.T) { diff --git a/lfs/http.go b/lfs/http.go index 3f8ccad9..8e94380f 100644 --- a/lfs/http.go +++ b/lfs/http.go @@ -11,7 +11,7 @@ import ( "strings" "time" - "github.com/rubyist/tracerx" + "github.com/github/git-lfs/vendor/_nuts/github.com/rubyist/tracerx" ) func DoHTTP(c *Configuration, req *http.Request) (*http.Response, error) { diff --git a/lfs/lfs.go b/lfs/lfs.go index c0c4d805..93251bd3 100644 --- a/lfs/lfs.go +++ b/lfs/lfs.go @@ -9,7 +9,7 @@ import ( "strings" "github.com/github/git-lfs/git" - "github.com/rubyist/tracerx" + "github.com/github/git-lfs/vendor/_nuts/github.com/rubyist/tracerx" ) const Version = "0.5.1" diff --git a/lfs/pointer_smudge.go b/lfs/pointer_smudge.go index 81c8dfa2..c82e484b 100644 --- a/lfs/pointer_smudge.go +++ b/lfs/pointer_smudge.go @@ -6,9 +6,9 @@ import ( "os" "path/filepath" - "github.com/cheggaaa/pb" - "github.com/rubyist/tracerx" - contentaddressable "github.com/technoweenie/go-contentaddressable" + "github.com/github/git-lfs/vendor/_nuts/github.com/cheggaaa/pb" + "github.com/github/git-lfs/vendor/_nuts/github.com/rubyist/tracerx" + contentaddressable "github.com/github/git-lfs/vendor/_nuts/github.com/technoweenie/go-contentaddressable" ) func PointerSmudge(writer io.Writer, ptr *Pointer, workingfile string, cb CopyCallback) error { diff --git a/lfs/pointer_test.go b/lfs/pointer_test.go index 47aa6d77..e86b9cb1 100644 --- a/lfs/pointer_test.go +++ b/lfs/pointer_test.go @@ -6,7 +6,7 @@ import ( "strings" "testing" - "github.com/bmizerany/assert" + "github.com/github/git-lfs/vendor/_nuts/github.com/technoweenie/assert" ) func TestEncode(t *testing.T) { diff --git a/lfs/scanner.go b/lfs/scanner.go index 0478e45d..9051c73f 100644 --- a/lfs/scanner.go +++ b/lfs/scanner.go @@ -10,7 +10,7 @@ import ( "strings" "time" - "github.com/rubyist/tracerx" + "github.com/github/git-lfs/vendor/_nuts/github.com/rubyist/tracerx" ) const ( diff --git a/lfs/ssh.go b/lfs/ssh.go index c8c8d88b..ef659ad8 100644 --- a/lfs/ssh.go +++ b/lfs/ssh.go @@ -4,7 +4,7 @@ import ( "encoding/json" "os/exec" - "github.com/rubyist/tracerx" + "github.com/github/git-lfs/vendor/_nuts/github.com/rubyist/tracerx" ) type sshAuthResponse struct { diff --git a/lfs/transfer_queue.go b/lfs/transfer_queue.go index 477a598b..3dcb90bf 100644 --- a/lfs/transfer_queue.go +++ b/lfs/transfer_queue.go @@ -5,7 +5,7 @@ import ( "sync" "sync/atomic" - "github.com/cheggaaa/pb" + "github.com/github/git-lfs/vendor/_nuts/github.com/cheggaaa/pb" ) type Transferable interface { diff --git a/lfs/util_test.go b/lfs/util_test.go index 6a2d84cf..c20ead75 100644 --- a/lfs/util_test.go +++ b/lfs/util_test.go @@ -5,7 +5,7 @@ import ( "io/ioutil" "testing" - "github.com/bmizerany/assert" + "github.com/github/git-lfs/vendor/_nuts/github.com/technoweenie/assert" ) func TestWriterWithCallback(t *testing.T) { diff --git a/script/bootstrap b/script/bootstrap index ad26bdd4..c10c2912 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -1,14 +1,5 @@ #!/bin/sh script/fmt - rm -rf `pwd`/bin/* -rm -rf `pwd`/.vendor/pkg - -export LOCALSRCDIR=`pwd`/.vendor/src/github.com/github/git-lfs -mkdir -p `dirname $LOCALSRCDIR` -rm -f $LOCALSRCDIR -ln -s `pwd` $LOCALSRCDIR - -GOPATH="`pwd`/.vendor" \ - go run script/*.go -cmd build "$@" +go run script/*.go -cmd build "$@" diff --git a/script/build.go b/script/build.go index eec45732..e119d7ef 100644 --- a/script/build.go +++ b/script/build.go @@ -94,15 +94,7 @@ func build(buildos, buildarch string, buildMatrix map[string]Release) error { dir = filepath.Join(dir, "releases", buildos+"-"+buildarch, name) } - filepath.Walk("cmd/git-lfs", func(path string, info os.FileInfo, err error) error { - if !strings.HasSuffix(path, ".go") { - return nil - } - - cmd := filepath.Base(path) - cmd = cmd[0 : len(cmd)-3] - return buildCommand(path, dir, buildos, buildarch) - }) + buildCommand(dir, buildos, buildarch) if addenv { err := os.MkdirAll(dir, 0755) @@ -121,18 +113,16 @@ func build(buildos, buildarch string, buildMatrix map[string]Release) error { return nil } -func buildCommand(path, dir, buildos, buildarch string) error { +func buildCommand(dir, buildos, buildarch string) error { addenv := len(buildos) > 0 && len(buildarch) > 0 - name := filepath.Base(path) - name = name[0 : len(name)-3] - bin := filepath.Join(dir, name) + bin := filepath.Join(dir, "git-lfs") if buildos == "windows" { bin = bin + ".exe" } - cmd := exec.Command("go", "build", "-o", bin, path) + cmd := exec.Command("go", "build", "-o", bin, ".") if addenv { cmd.Env = []string{ "GOOS=" + buildos, diff --git a/script/fmt b/script/fmt index a94a19cc..0f3f8a12 100755 --- a/script/fmt +++ b/script/fmt @@ -6,7 +6,7 @@ hash goimports 2>/dev/null && { } # don't run gofmt in these directories -ignored=(/bin/ /docs/ /log/ /man/ /tmp/ .vendor) +ignored=(/bin/ /docs/ /log/ /man/ /tmp/ /vendor/) for i in */ ; do if [[ ! ${ignored[*]} =~ "/$i" ]]; then $formatter -w -l "$@" "${i%?}" diff --git a/script/gpm b/script/gpm deleted file mode 100755 index d6b6babd..00000000 --- a/script/gpm +++ /dev/null @@ -1,114 +0,0 @@ -#!/usr/bin/env bash -# Copied from https://github.com/pote/gpm -# -# The MIT License -# -# Copyright (c) 2013 Pablo Astigarraga -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# -# -set -eu - -## Functions/ -usage() { -cat << EOF -SYNOPSIS - - gpm leverages the power of the go get command and the underlying version - control systems used by it to set your Go dependencies to desired versions, - thus allowing easily reproducible builds in your Go projects. - - A Godeps file in the root of your Go application is expected containing - the import paths of your packages and a specific tag or commit hash - from its version control system, an example Godeps file looks like this: - - $ cat Godeps - # This is a comment - github.com/nu7hatch/gotrail v0.0.2 - github.com/replicon/fast-archiver v1.02 #This is another comment! - github.com/nu7hatch/gotrail 2eb79d1f03ab24bacbc32b15b75769880629a865 - - gpm has a companion tool, called [gvp](https://github.com/pote/gvp) which - provides vendoring functionalities, it alters your GOPATH so every project - has its own isolated dependency directory, it's usage is recommended. - -USAGE - $ gpm # Same as 'install'. - $ gpm install # Parses the Godeps file, installs dependencies and sets - # them to the appropriate version. - $ gpm version # Outputs version information - $ gpm help # Prints this message -EOF -} - -# Iterates over Godep file dependencies and sets -# the specified version on each of them. -set_dependencies() { - deps=$(sed 's/#.*//;/^\s*$/d' < $1) || echo "" - - while read package version; do - ( - install_path="${GOPATH%%:*}/src/${package%%/...}" - [[ -e "$install_path/.git/index.lock" || - -e "$install_path/.hg/store/lock" || - -e "$install_path/.bzr/checkout/lock" ]] && wait - echo ">> Getting package "$package"" - go get -u -d "$package" - echo ">> Setting $package to version $version" - cd $install_path - [ -d .hg ] && hg update -q "$version" - [ -d .git ] && git checkout -q "$version" - [ -d .bzr ] && bzr revert -q -r "$version" - [ -d .svn ] && svn update -r "$version" - ) & - done < <(echo "$deps") - wait - echo ">> All Done" -} - -## /Functions -case "${1:-"install"}" in - "version") - echo ">> gpm v1.2.0" - ;; - "install") - deps_file="Godeps" - [[ "$#" -eq 2 ]] && [[ -n "$2" ]] && deps_file="$2" - [[ -f "$deps_file" ]] || (echo ">> $deps_file file does not exist." && exit 1) - (which go > /dev/null) || - ( echo ">> Go is currently not installed or in your PATH" && exit 1) - set_dependencies $deps_file - ;; - "help") - usage - ;; - *) - ## Support for Plugins: if command is unknown search for a gpm-command executable. - if command -v "gpm-$1" > /dev/null - then - plugin=$1 && - shift && - gpm-$plugin $@ && - exit - else - usage && exit 1 - fi - ;; -esac diff --git a/script/release b/script/release index 683ceadb..ead8d1fb 100755 --- a/script/release +++ b/script/release @@ -1,4 +1,3 @@ #!/bin/sh script/fmt -GOPATH="`pwd`/.vendor" \ - go run script/*.go -cmd release "$@" +go run script/*.go -cmd release "$@" diff --git a/script/run b/script/run index dc91bf97..0c358282 100755 --- a/script/run +++ b/script/run @@ -1,2 +1,3 @@ +#!/bin/sh script/fmt -GOPATH="`pwd`/.vendor" go run cmd/git-lfs/git-lfs.go "$@" +go run ./git-lfs.go "$@" diff --git a/script/test b/script/test index 8881603e..1432ed57 100755 --- a/script/test +++ b/script/test @@ -3,15 +3,8 @@ #/ script/test # run just a package's tests script/fmt - -export LOCALSRCDIR=`pwd`/.vendor/src/github.com/github/git-lfs -mkdir -p `dirname $LOCALSRCDIR` -rm -f $LOCALSRCDIR -ln -s `pwd` $LOCALSRCDIR - -GOPATH="`pwd`/.vendor" -SUITE="./${1:-"lfs"}" +suite="./${1:-"lfs"}" if [ $# -gt 0 ]; then shift fi -PATH=$LOCALSRCDIR/bin:$PATH GOPATH=$GOPATH go test $SUITE "$@" +go test $suite "$@" diff --git a/script/vendor b/script/vendor index 4ffbd94e..b5e40b77 100755 --- a/script/vendor +++ b/script/vendor @@ -1 +1,2 @@ -GOPATH="`pwd`/.vendor" script/gpm install +#!/bin/sh +nut install diff --git a/test/README.md b/test/README.md index 545e94d7..1bf48e0e 100644 --- a/test/README.md +++ b/test/README.md @@ -33,7 +33,7 @@ github.com/rubyist/tracerx github.com/technoweenie/go-contentaddressable github.com/kr/pretty github.com/github/git-lfs/git -github.com/bmizerany/assert +github.com/technoweenie/assert === RUN TestSuccessStatus --- PASS: TestSuccessStatus (0.00 seconds) PASS diff --git a/.vendor/src/github.com/cheggaaa/pb/LICENSE b/vendor/_nuts/github.com/cheggaaa/pb/LICENSE similarity index 100% rename from .vendor/src/github.com/cheggaaa/pb/LICENSE rename to vendor/_nuts/github.com/cheggaaa/pb/LICENSE diff --git a/.vendor/src/github.com/cheggaaa/pb/README.md b/vendor/_nuts/github.com/cheggaaa/pb/README.md similarity index 100% rename from .vendor/src/github.com/cheggaaa/pb/README.md rename to vendor/_nuts/github.com/cheggaaa/pb/README.md diff --git a/.vendor/src/github.com/cheggaaa/pb/example/copy/copy.go b/vendor/_nuts/github.com/cheggaaa/pb/example/copy/copy.go similarity index 95% rename from .vendor/src/github.com/cheggaaa/pb/example/copy/copy.go rename to vendor/_nuts/github.com/cheggaaa/pb/example/copy/copy.go index 82b5329a..0fffd728 100644 --- a/.vendor/src/github.com/cheggaaa/pb/example/copy/copy.go +++ b/vendor/_nuts/github.com/cheggaaa/pb/example/copy/copy.go @@ -2,7 +2,7 @@ package main import ( "fmt" - "github.com/cheggaaa/pb" + "github.com/github/git-lfs/vendor/_nuts/github.com/cheggaaa/pb" "io" "net/http" "os" diff --git a/.vendor/src/github.com/cheggaaa/pb/example/pb.go b/vendor/_nuts/github.com/cheggaaa/pb/example/pb.go similarity index 86% rename from .vendor/src/github.com/cheggaaa/pb/example/pb.go rename to vendor/_nuts/github.com/cheggaaa/pb/example/pb.go index 140ba039..eee92ff0 100644 --- a/.vendor/src/github.com/cheggaaa/pb/example/pb.go +++ b/vendor/_nuts/github.com/cheggaaa/pb/example/pb.go @@ -1,7 +1,7 @@ package main import ( - "github.com/cheggaaa/pb" + "github.com/github/git-lfs/vendor/_nuts/github.com/cheggaaa/pb" "time" ) diff --git a/.vendor/src/github.com/cheggaaa/pb/format.go b/vendor/_nuts/github.com/cheggaaa/pb/format.go similarity index 100% rename from .vendor/src/github.com/cheggaaa/pb/format.go rename to vendor/_nuts/github.com/cheggaaa/pb/format.go diff --git a/.vendor/src/github.com/cheggaaa/pb/format_test.go b/vendor/_nuts/github.com/cheggaaa/pb/format_test.go similarity index 100% rename from .vendor/src/github.com/cheggaaa/pb/format_test.go rename to vendor/_nuts/github.com/cheggaaa/pb/format_test.go diff --git a/.vendor/src/github.com/cheggaaa/pb/pb.go b/vendor/_nuts/github.com/cheggaaa/pb/pb.go similarity index 100% rename from .vendor/src/github.com/cheggaaa/pb/pb.go rename to vendor/_nuts/github.com/cheggaaa/pb/pb.go diff --git a/.vendor/src/github.com/cheggaaa/pb/pb_nix.go b/vendor/_nuts/github.com/cheggaaa/pb/pb_nix.go similarity index 100% rename from .vendor/src/github.com/cheggaaa/pb/pb_nix.go rename to vendor/_nuts/github.com/cheggaaa/pb/pb_nix.go diff --git a/.vendor/src/github.com/cheggaaa/pb/pb_solaris.go b/vendor/_nuts/github.com/cheggaaa/pb/pb_solaris.go similarity index 100% rename from .vendor/src/github.com/cheggaaa/pb/pb_solaris.go rename to vendor/_nuts/github.com/cheggaaa/pb/pb_solaris.go diff --git a/.vendor/src/github.com/cheggaaa/pb/pb_test.go b/vendor/_nuts/github.com/cheggaaa/pb/pb_test.go similarity index 100% rename from .vendor/src/github.com/cheggaaa/pb/pb_test.go rename to vendor/_nuts/github.com/cheggaaa/pb/pb_test.go diff --git a/.vendor/src/github.com/cheggaaa/pb/pb_win.go b/vendor/_nuts/github.com/cheggaaa/pb/pb_win.go similarity index 72% rename from .vendor/src/github.com/cheggaaa/pb/pb_win.go rename to vendor/_nuts/github.com/cheggaaa/pb/pb_win.go index eb36190c..c700a5aa 100644 --- a/.vendor/src/github.com/cheggaaa/pb/pb_win.go +++ b/vendor/_nuts/github.com/cheggaaa/pb/pb_win.go @@ -3,7 +3,7 @@ package pb import ( - "github.com/olekukonko/ts" + "github.com/github/git-lfs/vendor/_nuts/github.com/olekukonko/ts" ) func bold(str string) string { diff --git a/.vendor/src/github.com/cheggaaa/pb/pb_x.go b/vendor/_nuts/github.com/cheggaaa/pb/pb_x.go similarity index 100% rename from .vendor/src/github.com/cheggaaa/pb/pb_x.go rename to vendor/_nuts/github.com/cheggaaa/pb/pb_x.go diff --git a/.vendor/src/github.com/cheggaaa/pb/reader.go b/vendor/_nuts/github.com/cheggaaa/pb/reader.go similarity index 100% rename from .vendor/src/github.com/cheggaaa/pb/reader.go rename to vendor/_nuts/github.com/cheggaaa/pb/reader.go diff --git a/.vendor/src/github.com/kr/pretty/.gitignore b/vendor/_nuts/github.com/kr/pretty/.gitignore similarity index 100% rename from .vendor/src/github.com/kr/pretty/.gitignore rename to vendor/_nuts/github.com/kr/pretty/.gitignore diff --git a/.vendor/src/github.com/kr/pretty/License b/vendor/_nuts/github.com/kr/pretty/License similarity index 100% rename from .vendor/src/github.com/kr/pretty/License rename to vendor/_nuts/github.com/kr/pretty/License diff --git a/.vendor/src/github.com/kr/pretty/Readme b/vendor/_nuts/github.com/kr/pretty/Readme similarity index 100% rename from .vendor/src/github.com/kr/pretty/Readme rename to vendor/_nuts/github.com/kr/pretty/Readme diff --git a/.vendor/src/github.com/kr/pretty/diff.go b/vendor/_nuts/github.com/kr/pretty/diff.go similarity index 100% rename from .vendor/src/github.com/kr/pretty/diff.go rename to vendor/_nuts/github.com/kr/pretty/diff.go diff --git a/.vendor/src/github.com/kr/pretty/diff_test.go b/vendor/_nuts/github.com/kr/pretty/diff_test.go similarity index 100% rename from .vendor/src/github.com/kr/pretty/diff_test.go rename to vendor/_nuts/github.com/kr/pretty/diff_test.go diff --git a/.vendor/src/github.com/kr/pretty/example_test.go b/vendor/_nuts/github.com/kr/pretty/example_test.go similarity index 81% rename from .vendor/src/github.com/kr/pretty/example_test.go rename to vendor/_nuts/github.com/kr/pretty/example_test.go index ecf40f3f..f192163c 100644 --- a/.vendor/src/github.com/kr/pretty/example_test.go +++ b/vendor/_nuts/github.com/kr/pretty/example_test.go @@ -2,7 +2,7 @@ package pretty_test import ( "fmt" - "github.com/kr/pretty" + "github.com/github/git-lfs/vendor/_nuts/github.com/kr/pretty" ) func Example() { diff --git a/.vendor/src/github.com/kr/pretty/formatter.go b/vendor/_nuts/github.com/kr/pretty/formatter.go similarity index 99% rename from .vendor/src/github.com/kr/pretty/formatter.go rename to vendor/_nuts/github.com/kr/pretty/formatter.go index c834d464..07652978 100644 --- a/.vendor/src/github.com/kr/pretty/formatter.go +++ b/vendor/_nuts/github.com/kr/pretty/formatter.go @@ -7,7 +7,7 @@ import ( "strconv" "text/tabwriter" - "github.com/kr/text" + "github.com/github/git-lfs/vendor/_nuts/github.com/kr/text" ) const ( diff --git a/.vendor/src/github.com/kr/pretty/formatter_test.go b/vendor/_nuts/github.com/kr/pretty/formatter_test.go similarity index 100% rename from .vendor/src/github.com/kr/pretty/formatter_test.go rename to vendor/_nuts/github.com/kr/pretty/formatter_test.go diff --git a/.vendor/src/github.com/kr/pretty/pretty.go b/vendor/_nuts/github.com/kr/pretty/pretty.go similarity index 100% rename from .vendor/src/github.com/kr/pretty/pretty.go rename to vendor/_nuts/github.com/kr/pretty/pretty.go diff --git a/.vendor/src/github.com/kr/pretty/zero.go b/vendor/_nuts/github.com/kr/pretty/zero.go similarity index 100% rename from .vendor/src/github.com/kr/pretty/zero.go rename to vendor/_nuts/github.com/kr/pretty/zero.go diff --git a/vendor/_nuts/github.com/kr/pty/.gitignore b/vendor/_nuts/github.com/kr/pty/.gitignore new file mode 100644 index 00000000..1f0a99f2 --- /dev/null +++ b/vendor/_nuts/github.com/kr/pty/.gitignore @@ -0,0 +1,4 @@ +[568].out +_go* +_test* +_obj diff --git a/vendor/_nuts/github.com/kr/pty/License b/vendor/_nuts/github.com/kr/pty/License new file mode 100644 index 00000000..6b7558b6 --- /dev/null +++ b/vendor/_nuts/github.com/kr/pty/License @@ -0,0 +1,23 @@ +Copyright (c) 2011 Keith Rarick + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall +be included in all copies or substantial portions of the +Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS +OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/_nuts/github.com/kr/pty/README.md b/vendor/_nuts/github.com/kr/pty/README.md new file mode 100644 index 00000000..7b7900c3 --- /dev/null +++ b/vendor/_nuts/github.com/kr/pty/README.md @@ -0,0 +1,36 @@ +# pty + +Pty is a Go package for using unix pseudo-terminals. + +## Install + + go get github.com/kr/pty + +## Example + +```go +package main + +import ( + "github.com/kr/pty" + "io" + "os" + "os/exec" +) + +func main() { + c := exec.Command("grep", "--color=auto", "bar") + f, err := pty.Start(c) + if err != nil { + panic(err) + } + + go func() { + f.Write([]byte("foo\n")) + f.Write([]byte("bar\n")) + f.Write([]byte("baz\n")) + f.Write([]byte{4}) // EOT + }() + io.Copy(os.Stdout, f) +} +``` diff --git a/vendor/_nuts/github.com/kr/pty/doc.go b/vendor/_nuts/github.com/kr/pty/doc.go new file mode 100644 index 00000000..190cfbea --- /dev/null +++ b/vendor/_nuts/github.com/kr/pty/doc.go @@ -0,0 +1,16 @@ +// Package pty provides functions for working with Unix terminals. +package pty + +import ( + "errors" + "os" +) + +// ErrUnsupported is returned if a function is not +// available on the current platform. +var ErrUnsupported = errors.New("unsupported") + +// Opens a pty and its corresponding tty. +func Open() (pty, tty *os.File, err error) { + return open() +} diff --git a/vendor/_nuts/github.com/kr/pty/ioctl.go b/vendor/_nuts/github.com/kr/pty/ioctl.go new file mode 100644 index 00000000..5b856e87 --- /dev/null +++ b/vendor/_nuts/github.com/kr/pty/ioctl.go @@ -0,0 +1,11 @@ +package pty + +import "syscall" + +func ioctl(fd, cmd, ptr uintptr) error { + _, _, e := syscall.Syscall(syscall.SYS_IOCTL, fd, cmd, ptr) + if e != 0 { + return e + } + return nil +} diff --git a/vendor/_nuts/github.com/kr/pty/ioctl_bsd.go b/vendor/_nuts/github.com/kr/pty/ioctl_bsd.go new file mode 100644 index 00000000..73b12c53 --- /dev/null +++ b/vendor/_nuts/github.com/kr/pty/ioctl_bsd.go @@ -0,0 +1,39 @@ +// +build darwin dragonfly freebsd netbsd openbsd + +package pty + +// from +const ( + _IOC_VOID uintptr = 0x20000000 + _IOC_OUT uintptr = 0x40000000 + _IOC_IN uintptr = 0x80000000 + _IOC_IN_OUT uintptr = _IOC_OUT | _IOC_IN + _IOC_DIRMASK = _IOC_VOID | _IOC_OUT | _IOC_IN + + _IOC_PARAM_SHIFT = 13 + _IOC_PARAM_MASK = (1 << _IOC_PARAM_SHIFT) - 1 +) + +func _IOC_PARM_LEN(ioctl uintptr) uintptr { + return (ioctl >> 16) & _IOC_PARAM_MASK +} + +func _IOC(inout uintptr, group byte, ioctl_num uintptr, param_len uintptr) uintptr { + return inout | (param_len&_IOC_PARAM_MASK)<<16 | uintptr(group)<<8 | ioctl_num +} + +func _IO(group byte, ioctl_num uintptr) uintptr { + return _IOC(_IOC_VOID, group, ioctl_num, 0) +} + +func _IOR(group byte, ioctl_num uintptr, param_len uintptr) uintptr { + return _IOC(_IOC_OUT, group, ioctl_num, param_len) +} + +func _IOW(group byte, ioctl_num uintptr, param_len uintptr) uintptr { + return _IOC(_IOC_IN, group, ioctl_num, param_len) +} + +func _IOWR(group byte, ioctl_num uintptr, param_len uintptr) uintptr { + return _IOC(_IOC_IN_OUT, group, ioctl_num, param_len) +} diff --git a/vendor/_nuts/github.com/kr/pty/mktypes.bash b/vendor/_nuts/github.com/kr/pty/mktypes.bash new file mode 100644 index 00000000..9952c888 --- /dev/null +++ b/vendor/_nuts/github.com/kr/pty/mktypes.bash @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +GOOSARCH="${GOOS}_${GOARCH}" +case "$GOOSARCH" in +_* | *_ | _) + echo 'undefined $GOOS_$GOARCH:' "$GOOSARCH" 1>&2 + exit 1 + ;; +esac + +GODEFS="go tool cgo -godefs" + +$GODEFS types.go |gofmt > ztypes_$GOARCH.go + +case $GOOS in +freebsd) + $GODEFS types_$GOOS.go |gofmt > ztypes_$GOOSARCH.go + ;; +esac diff --git a/vendor/_nuts/github.com/kr/pty/pty_darwin.go b/vendor/_nuts/github.com/kr/pty/pty_darwin.go new file mode 100644 index 00000000..4f4d5ca2 --- /dev/null +++ b/vendor/_nuts/github.com/kr/pty/pty_darwin.go @@ -0,0 +1,60 @@ +package pty + +import ( + "errors" + "os" + "syscall" + "unsafe" +) + +func open() (pty, tty *os.File, err error) { + p, err := os.OpenFile("/dev/ptmx", os.O_RDWR, 0) + if err != nil { + return nil, nil, err + } + + sname, err := ptsname(p) + if err != nil { + return nil, nil, err + } + + err = grantpt(p) + if err != nil { + return nil, nil, err + } + + err = unlockpt(p) + if err != nil { + return nil, nil, err + } + + t, err := os.OpenFile(sname, os.O_RDWR, 0) + if err != nil { + return nil, nil, err + } + return p, t, nil +} + +func ptsname(f *os.File) (string, error) { + n := make([]byte, _IOC_PARM_LEN(syscall.TIOCPTYGNAME)) + + err := ioctl(f.Fd(), syscall.TIOCPTYGNAME, uintptr(unsafe.Pointer(&n[0]))) + if err != nil { + return "", err + } + + for i, c := range n { + if c == 0 { + return string(n[:i]), nil + } + } + return "", errors.New("TIOCPTYGNAME string not NUL-terminated") +} + +func grantpt(f *os.File) error { + return ioctl(f.Fd(), syscall.TIOCPTYGRANT, 0) +} + +func unlockpt(f *os.File) error { + return ioctl(f.Fd(), syscall.TIOCPTYUNLK, 0) +} diff --git a/vendor/_nuts/github.com/kr/pty/pty_freebsd.go b/vendor/_nuts/github.com/kr/pty/pty_freebsd.go new file mode 100644 index 00000000..b341babd --- /dev/null +++ b/vendor/_nuts/github.com/kr/pty/pty_freebsd.go @@ -0,0 +1,73 @@ +package pty + +import ( + "errors" + "os" + "syscall" + "unsafe" +) + +func posix_openpt(oflag int) (fd int, err error) { + r0, _, e1 := syscall.Syscall(syscall.SYS_POSIX_OPENPT, uintptr(oflag), 0, 0) + fd = int(r0) + if e1 != 0 { + err = e1 + } + return +} + +func open() (pty, tty *os.File, err error) { + fd, err := posix_openpt(syscall.O_RDWR | syscall.O_CLOEXEC) + if err != nil { + return nil, nil, err + } + + p := os.NewFile(uintptr(fd), "/dev/pts") + sname, err := ptsname(p) + if err != nil { + return nil, nil, err + } + + t, err := os.OpenFile("/dev/"+sname, os.O_RDWR, 0) + if err != nil { + return nil, nil, err + } + return p, t, nil +} + +func isptmaster(fd uintptr) (bool, error) { + err := ioctl(fd, syscall.TIOCPTMASTER, 0) + return err == nil, err +} + +var ( + emptyFiodgnameArg fiodgnameArg + ioctl_FIODGNAME = _IOW('f', 120, unsafe.Sizeof(emptyFiodgnameArg)) +) + +func ptsname(f *os.File) (string, error) { + master, err := isptmaster(f.Fd()) + if err != nil { + return "", err + } + if !master { + return "", syscall.EINVAL + } + + const n = _C_SPECNAMELEN + 1 + var ( + buf = make([]byte, n) + arg = fiodgnameArg{Len: n, Buf: (*byte)(unsafe.Pointer(&buf[0]))} + ) + err = ioctl(f.Fd(), ioctl_FIODGNAME, uintptr(unsafe.Pointer(&arg))) + if err != nil { + return "", err + } + + for i, c := range buf { + if c == 0 { + return string(buf[:i]), nil + } + } + return "", errors.New("FIODGNAME string not NUL-terminated") +} diff --git a/vendor/_nuts/github.com/kr/pty/pty_linux.go b/vendor/_nuts/github.com/kr/pty/pty_linux.go new file mode 100644 index 00000000..cb901a21 --- /dev/null +++ b/vendor/_nuts/github.com/kr/pty/pty_linux.go @@ -0,0 +1,46 @@ +package pty + +import ( + "os" + "strconv" + "syscall" + "unsafe" +) + +func open() (pty, tty *os.File, err error) { + p, err := os.OpenFile("/dev/ptmx", os.O_RDWR, 0) + if err != nil { + return nil, nil, err + } + + sname, err := ptsname(p) + if err != nil { + return nil, nil, err + } + + err = unlockpt(p) + if err != nil { + return nil, nil, err + } + + t, err := os.OpenFile(sname, os.O_RDWR|syscall.O_NOCTTY, 0) + if err != nil { + return nil, nil, err + } + return p, t, nil +} + +func ptsname(f *os.File) (string, error) { + var n _C_uint + err := ioctl(f.Fd(), syscall.TIOCGPTN, uintptr(unsafe.Pointer(&n))) + if err != nil { + return "", err + } + return "/dev/pts/" + strconv.Itoa(int(n)), nil +} + +func unlockpt(f *os.File) error { + var u _C_int + // use TIOCSPTLCK with a zero valued arg to clear the slave pty lock + return ioctl(f.Fd(), syscall.TIOCSPTLCK, uintptr(unsafe.Pointer(&u))) +} diff --git a/vendor/_nuts/github.com/kr/pty/pty_unsupported.go b/vendor/_nuts/github.com/kr/pty/pty_unsupported.go new file mode 100644 index 00000000..898c7303 --- /dev/null +++ b/vendor/_nuts/github.com/kr/pty/pty_unsupported.go @@ -0,0 +1,11 @@ +// +build !linux,!darwin,!freebsd + +package pty + +import ( + "os" +) + +func open() (pty, tty *os.File, err error) { + return nil, nil, ErrUnsupported +} diff --git a/vendor/_nuts/github.com/kr/pty/run.go b/vendor/_nuts/github.com/kr/pty/run.go new file mode 100644 index 00000000..f0678d2a --- /dev/null +++ b/vendor/_nuts/github.com/kr/pty/run.go @@ -0,0 +1,28 @@ +package pty + +import ( + "os" + "os/exec" + "syscall" +) + +// Start assigns a pseudo-terminal tty os.File to c.Stdin, c.Stdout, +// and c.Stderr, calls c.Start, and returns the File of the tty's +// corresponding pty. +func Start(c *exec.Cmd) (pty *os.File, err error) { + pty, tty, err := Open() + if err != nil { + return nil, err + } + defer tty.Close() + c.Stdout = tty + c.Stdin = tty + c.Stderr = tty + c.SysProcAttr = &syscall.SysProcAttr{Setctty: true, Setsid: true} + err = c.Start() + if err != nil { + pty.Close() + return nil, err + } + return pty, err +} diff --git a/vendor/_nuts/github.com/kr/pty/types.go b/vendor/_nuts/github.com/kr/pty/types.go new file mode 100644 index 00000000..5aecb6bc --- /dev/null +++ b/vendor/_nuts/github.com/kr/pty/types.go @@ -0,0 +1,10 @@ +// +build ignore + +package pty + +import "C" + +type ( + _C_int C.int + _C_uint C.uint +) diff --git a/vendor/_nuts/github.com/kr/pty/types_freebsd.go b/vendor/_nuts/github.com/kr/pty/types_freebsd.go new file mode 100644 index 00000000..ce3eb951 --- /dev/null +++ b/vendor/_nuts/github.com/kr/pty/types_freebsd.go @@ -0,0 +1,15 @@ +// +build ignore + +package pty + +/* +#include +#include +*/ +import "C" + +const ( + _C_SPECNAMELEN = C.SPECNAMELEN /* max length of devicename */ +) + +type fiodgnameArg C.struct_fiodgname_arg diff --git a/vendor/_nuts/github.com/kr/pty/util.go b/vendor/_nuts/github.com/kr/pty/util.go new file mode 100644 index 00000000..67c52d06 --- /dev/null +++ b/vendor/_nuts/github.com/kr/pty/util.go @@ -0,0 +1,35 @@ +package pty + +import ( + "os" + "syscall" + "unsafe" +) + +// Getsize returns the number of rows (lines) and cols (positions +// in each line) in terminal t. +func Getsize(t *os.File) (rows, cols int, err error) { + var ws winsize + err = windowrect(&ws, t.Fd()) + return int(ws.ws_row), int(ws.ws_col), err +} + +type winsize struct { + ws_row uint16 + ws_col uint16 + ws_xpixel uint16 + ws_ypixel uint16 +} + +func windowrect(ws *winsize, fd uintptr) error { + _, _, errno := syscall.Syscall( + syscall.SYS_IOCTL, + fd, + syscall.TIOCGWINSZ, + uintptr(unsafe.Pointer(ws)), + ) + if errno != 0 { + return syscall.Errno(errno) + } + return nil +} diff --git a/vendor/_nuts/github.com/kr/pty/ztypes_386.go b/vendor/_nuts/github.com/kr/pty/ztypes_386.go new file mode 100644 index 00000000..ff0b8fd8 --- /dev/null +++ b/vendor/_nuts/github.com/kr/pty/ztypes_386.go @@ -0,0 +1,9 @@ +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types.go + +package pty + +type ( + _C_int int32 + _C_uint uint32 +) diff --git a/vendor/_nuts/github.com/kr/pty/ztypes_amd64.go b/vendor/_nuts/github.com/kr/pty/ztypes_amd64.go new file mode 100644 index 00000000..ff0b8fd8 --- /dev/null +++ b/vendor/_nuts/github.com/kr/pty/ztypes_amd64.go @@ -0,0 +1,9 @@ +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types.go + +package pty + +type ( + _C_int int32 + _C_uint uint32 +) diff --git a/vendor/_nuts/github.com/kr/pty/ztypes_arm.go b/vendor/_nuts/github.com/kr/pty/ztypes_arm.go new file mode 100644 index 00000000..ff0b8fd8 --- /dev/null +++ b/vendor/_nuts/github.com/kr/pty/ztypes_arm.go @@ -0,0 +1,9 @@ +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types.go + +package pty + +type ( + _C_int int32 + _C_uint uint32 +) diff --git a/vendor/_nuts/github.com/kr/pty/ztypes_arm64.go b/vendor/_nuts/github.com/kr/pty/ztypes_arm64.go new file mode 100644 index 00000000..6c29a4b9 --- /dev/null +++ b/vendor/_nuts/github.com/kr/pty/ztypes_arm64.go @@ -0,0 +1,11 @@ +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types.go + +// +build arm64 + +package pty + +type ( + _C_int int32 + _C_uint uint32 +) diff --git a/vendor/_nuts/github.com/kr/pty/ztypes_freebsd_386.go b/vendor/_nuts/github.com/kr/pty/ztypes_freebsd_386.go new file mode 100644 index 00000000..d9975374 --- /dev/null +++ b/vendor/_nuts/github.com/kr/pty/ztypes_freebsd_386.go @@ -0,0 +1,13 @@ +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_freebsd.go + +package pty + +const ( + _C_SPECNAMELEN = 0x3f +) + +type fiodgnameArg struct { + Len int32 + Buf *byte +} diff --git a/vendor/_nuts/github.com/kr/pty/ztypes_freebsd_amd64.go b/vendor/_nuts/github.com/kr/pty/ztypes_freebsd_amd64.go new file mode 100644 index 00000000..5fa102fc --- /dev/null +++ b/vendor/_nuts/github.com/kr/pty/ztypes_freebsd_amd64.go @@ -0,0 +1,14 @@ +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_freebsd.go + +package pty + +const ( + _C_SPECNAMELEN = 0x3f +) + +type fiodgnameArg struct { + Len int32 + Pad_cgo_0 [4]byte + Buf *byte +} diff --git a/vendor/_nuts/github.com/kr/pty/ztypes_freebsd_arm.go b/vendor/_nuts/github.com/kr/pty/ztypes_freebsd_arm.go new file mode 100644 index 00000000..d9975374 --- /dev/null +++ b/vendor/_nuts/github.com/kr/pty/ztypes_freebsd_arm.go @@ -0,0 +1,13 @@ +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_freebsd.go + +package pty + +const ( + _C_SPECNAMELEN = 0x3f +) + +type fiodgnameArg struct { + Len int32 + Buf *byte +} diff --git a/vendor/_nuts/github.com/kr/pty/ztypes_ppc64.go b/vendor/_nuts/github.com/kr/pty/ztypes_ppc64.go new file mode 100644 index 00000000..4e1af843 --- /dev/null +++ b/vendor/_nuts/github.com/kr/pty/ztypes_ppc64.go @@ -0,0 +1,11 @@ +// +build ppc64 + +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types.go + +package pty + +type ( + _C_int int32 + _C_uint uint32 +) diff --git a/vendor/_nuts/github.com/kr/pty/ztypes_ppc64le.go b/vendor/_nuts/github.com/kr/pty/ztypes_ppc64le.go new file mode 100644 index 00000000..e6780f4e --- /dev/null +++ b/vendor/_nuts/github.com/kr/pty/ztypes_ppc64le.go @@ -0,0 +1,11 @@ +// +build ppc64le + +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types.go + +package pty + +type ( + _C_int int32 + _C_uint uint32 +) diff --git a/vendor/_nuts/github.com/kr/pty/ztypes_s390x.go b/vendor/_nuts/github.com/kr/pty/ztypes_s390x.go new file mode 100644 index 00000000..a7452b61 --- /dev/null +++ b/vendor/_nuts/github.com/kr/pty/ztypes_s390x.go @@ -0,0 +1,11 @@ +// +build s390x + +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types.go + +package pty + +type ( + _C_int int32 + _C_uint uint32 +) diff --git a/.vendor/src/github.com/kr/text/License b/vendor/_nuts/github.com/kr/text/License similarity index 100% rename from .vendor/src/github.com/kr/text/License rename to vendor/_nuts/github.com/kr/text/License diff --git a/.vendor/src/github.com/kr/text/Readme b/vendor/_nuts/github.com/kr/text/Readme similarity index 100% rename from .vendor/src/github.com/kr/text/Readme rename to vendor/_nuts/github.com/kr/text/Readme diff --git a/.vendor/src/github.com/kr/text/colwriter/Readme b/vendor/_nuts/github.com/kr/text/colwriter/Readme similarity index 100% rename from .vendor/src/github.com/kr/text/colwriter/Readme rename to vendor/_nuts/github.com/kr/text/colwriter/Readme diff --git a/.vendor/src/github.com/kr/text/colwriter/column.go b/vendor/_nuts/github.com/kr/text/colwriter/column.go similarity index 100% rename from .vendor/src/github.com/kr/text/colwriter/column.go rename to vendor/_nuts/github.com/kr/text/colwriter/column.go diff --git a/.vendor/src/github.com/kr/text/colwriter/column_test.go b/vendor/_nuts/github.com/kr/text/colwriter/column_test.go similarity index 100% rename from .vendor/src/github.com/kr/text/colwriter/column_test.go rename to vendor/_nuts/github.com/kr/text/colwriter/column_test.go diff --git a/.vendor/src/github.com/kr/text/doc.go b/vendor/_nuts/github.com/kr/text/doc.go similarity index 100% rename from .vendor/src/github.com/kr/text/doc.go rename to vendor/_nuts/github.com/kr/text/doc.go diff --git a/.vendor/src/github.com/kr/text/indent.go b/vendor/_nuts/github.com/kr/text/indent.go similarity index 100% rename from .vendor/src/github.com/kr/text/indent.go rename to vendor/_nuts/github.com/kr/text/indent.go diff --git a/.vendor/src/github.com/kr/text/indent_test.go b/vendor/_nuts/github.com/kr/text/indent_test.go similarity index 100% rename from .vendor/src/github.com/kr/text/indent_test.go rename to vendor/_nuts/github.com/kr/text/indent_test.go diff --git a/.vendor/src/github.com/kr/text/mc/Readme b/vendor/_nuts/github.com/kr/text/mc/Readme similarity index 100% rename from .vendor/src/github.com/kr/text/mc/Readme rename to vendor/_nuts/github.com/kr/text/mc/Readme diff --git a/.vendor/src/github.com/kr/text/mc/mc.go b/vendor/_nuts/github.com/kr/text/mc/mc.go similarity index 90% rename from .vendor/src/github.com/kr/text/mc/mc.go rename to vendor/_nuts/github.com/kr/text/mc/mc.go index 00169a30..4c591aac 100644 --- a/.vendor/src/github.com/kr/text/mc/mc.go +++ b/vendor/_nuts/github.com/kr/text/mc/mc.go @@ -10,8 +10,8 @@ package main import ( - "github.com/kr/pty" - "github.com/kr/text/colwriter" + "github.com/github/git-lfs/vendor/_nuts/github.com/kr/pty" + "github.com/github/git-lfs/vendor/_nuts/github.com/kr/text/colwriter" "io" "log" "os" diff --git a/.vendor/src/github.com/kr/text/wrap.go b/vendor/_nuts/github.com/kr/text/wrap.go old mode 100755 new mode 100644 similarity index 100% rename from .vendor/src/github.com/kr/text/wrap.go rename to vendor/_nuts/github.com/kr/text/wrap.go diff --git a/.vendor/src/github.com/kr/text/wrap_test.go b/vendor/_nuts/github.com/kr/text/wrap_test.go similarity index 100% rename from .vendor/src/github.com/kr/text/wrap_test.go rename to vendor/_nuts/github.com/kr/text/wrap_test.go diff --git a/vendor/_nuts/github.com/ogier/pflag/.travis.yml b/vendor/_nuts/github.com/ogier/pflag/.travis.yml new file mode 100644 index 00000000..4f2ee4d9 --- /dev/null +++ b/vendor/_nuts/github.com/ogier/pflag/.travis.yml @@ -0,0 +1 @@ +language: go diff --git a/.vendor/src/github.com/spf13/pflag/LICENSE b/vendor/_nuts/github.com/ogier/pflag/LICENSE similarity index 100% rename from .vendor/src/github.com/spf13/pflag/LICENSE rename to vendor/_nuts/github.com/ogier/pflag/LICENSE diff --git a/vendor/_nuts/github.com/ogier/pflag/README.md b/vendor/_nuts/github.com/ogier/pflag/README.md new file mode 100644 index 00000000..d9b189f8 --- /dev/null +++ b/vendor/_nuts/github.com/ogier/pflag/README.md @@ -0,0 +1,157 @@ +[![Build Status](https://travis-ci.org/ogier/pflag.png?branch=master)](https://travis-ci.org/ogier/pflag) + +## Description + +pflag is a drop-in replacement for Go's flag package, implementing +POSIX/GNU-style --flags. + +pflag is compatible with the [GNU extensions to the POSIX recommendations +for command-line options][1]. For a more precise description, see the +"Command-line flag syntax" section below. + +[1]: http://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html + +pflag is available under the same style of BSD license as the Go language, +which can be found in the LICENSE file. + +## Installation + +pflag is available using the standard `go get` command. + +Install by running: + + go get github.com/ogier/pflag + +Run tests by running: + + go test github.com/ogier/pflag + +## Usage + +pflag is a drop-in replacement of Go's native flag package. If you import +pflag under the name "flag" then all code should continue to function +with no changes. + +``` go +import flag "github.com/ogier/pflag" +``` + +There is one exception to this: if you directly instantiate the Flag struct +there is one more field "Shorthand" that you will need to set. +Most code never instantiates this struct directly, and instead uses +functions such as String(), BoolVar(), and Var(), and is therefore +unaffected. + +Define flags using flag.String(), Bool(), Int(), etc. + +This declares an integer flag, -flagname, stored in the pointer ip, with type *int. + +``` go +var ip *int = flag.Int("flagname", 1234, "help message for flagname") +``` + +If you like, you can bind the flag to a variable using the Var() functions. + +``` go +var flagvar int +func init() { + flag.IntVar(&flagvar, "flagname", 1234, "help message for flagname") +} +``` + +Or you can create custom flags that satisfy the Value interface (with +pointer receivers) and couple them to flag parsing by + +``` go +flag.Var(&flagVal, "name", "help message for flagname") +``` + +For such flags, the default value is just the initial value of the variable. + +After all flags are defined, call + +``` go +flag.Parse() +``` + +to parse the command line into the defined flags. + +Flags may then be used directly. If you're using the flags themselves, +they are all pointers; if you bind to variables, they're values. + +``` go +fmt.Println("ip has value ", *ip) +fmt.Println("flagvar has value ", flagvar) +``` + +After parsing, the arguments after the flag are available as the +slice flag.Args() or individually as flag.Arg(i). +The arguments are indexed from 0 through flag.NArg()-1. + +The pflag package also defines some new functions that are not in flag, +that give one-letter shorthands for flags. You can use these by appending +'P' to the name of any function that defines a flag. + +``` go +var ip = flag.IntP("flagname", "f", 1234, "help message") +var flagvar bool +func init() { + flag.BoolVarP("boolname", "b", true, "help message") +} +flag.VarP(&flagVar, "varname", "v", 1234, "help message") +``` + +Shorthand letters can be used with single dashes on the command line. +Boolean shorthand flags can be combined with other shorthand flags. + +The default set of command-line flags is controlled by +top-level functions. The FlagSet type allows one to define +independent sets of flags, such as to implement subcommands +in a command-line interface. The methods of FlagSet are +analogous to the top-level functions for the command-line +flag set. + +## Command line flag syntax + +``` +--flag // boolean flags only +--flag=x +``` + +Unlike the flag package, a single dash before an option means something +different than a double dash. Single dashes signify a series of shorthand +letters for flags. All but the last shorthand letter must be boolean flags. + +``` +// boolean flags +-f +-abc + +// non-boolean flags +-n 1234 +-Ifile + +// mixed +-abcs "hello" +-abcn1234 +``` + +Flag parsing stops after the terminator "--". Unlike the flag package, +flags can be interspersed with arguments anywhere on the command line +before this terminator. + +Integer flags accept 1234, 0664, 0x1234 and may be negative. +Boolean flags (in their long form) accept 1, 0, t, f, true, false, +TRUE, FALSE, True, False. +Duration flags accept any input valid for time.ParseDuration. + +## More info + +You can see the full reference documentation of the pflag package +[at godoc.org][3], or through go's standard documentation system by +running `godoc -http=:6060` and browsing to +[http://localhost:6060/pkg/github.com/ogier/pflag][2] after +installation. + +[2]: http://localhost:6060/pkg/github.com/ogier/pflag +[3]: http://godoc.org/github.com/ogier/pflag diff --git a/vendor/_nuts/github.com/ogier/pflag/bool.go b/vendor/_nuts/github.com/ogier/pflag/bool.go new file mode 100644 index 00000000..617971a0 --- /dev/null +++ b/vendor/_nuts/github.com/ogier/pflag/bool.go @@ -0,0 +1,79 @@ +package pflag + +import ( + "fmt" + "strconv" +) + +// optional interface to indicate boolean flags that can be +// supplied without "=value" text +type boolFlag interface { + Value + IsBoolFlag() bool +} + +// -- bool Value +type boolValue bool + +func newBoolValue(val bool, p *bool) *boolValue { + *p = val + return (*boolValue)(p) +} + +func (b *boolValue) Set(s string) error { + v, err := strconv.ParseBool(s) + *b = boolValue(v) + return err +} + +func (b *boolValue) String() string { return fmt.Sprintf("%v", *b) } + +func (b *boolValue) IsBoolFlag() bool { return true } + +// BoolVar defines a bool flag with specified name, default value, and usage string. +// The argument p points to a bool variable in which to store the value of the flag. +func (f *FlagSet) BoolVar(p *bool, name string, value bool, usage string) { + f.VarP(newBoolValue(value, p), name, "", usage) +} + +// Like BoolVar, but accepts a shorthand letter that can be used after a single dash. +func (f *FlagSet) BoolVarP(p *bool, name, shorthand string, value bool, usage string) { + f.VarP(newBoolValue(value, p), name, shorthand, usage) +} + +// BoolVar defines a bool flag with specified name, default value, and usage string. +// The argument p points to a bool variable in which to store the value of the flag. +func BoolVar(p *bool, name string, value bool, usage string) { + CommandLine.VarP(newBoolValue(value, p), name, "", usage) +} + +// Like BoolVar, but accepts a shorthand letter that can be used after a single dash. +func BoolVarP(p *bool, name, shorthand string, value bool, usage string) { + CommandLine.VarP(newBoolValue(value, p), name, shorthand, usage) +} + +// Bool defines a bool flag with specified name, default value, and usage string. +// The return value is the address of a bool variable that stores the value of the flag. +func (f *FlagSet) Bool(name string, value bool, usage string) *bool { + p := new(bool) + f.BoolVarP(p, name, "", value, usage) + return p +} + +// Like Bool, but accepts a shorthand letter that can be used after a single dash. +func (f *FlagSet) BoolP(name, shorthand string, value bool, usage string) *bool { + p := new(bool) + f.BoolVarP(p, name, shorthand, value, usage) + return p +} + +// Bool defines a bool flag with specified name, default value, and usage string. +// The return value is the address of a bool variable that stores the value of the flag. +func Bool(name string, value bool, usage string) *bool { + return CommandLine.BoolP(name, "", value, usage) +} + +// Like Bool, but accepts a shorthand letter that can be used after a single dash. +func BoolP(name, shorthand string, value bool, usage string) *bool { + return CommandLine.BoolP(name, shorthand, value, usage) +} diff --git a/vendor/_nuts/github.com/ogier/pflag/bool_test.go b/vendor/_nuts/github.com/ogier/pflag/bool_test.go new file mode 100644 index 00000000..a2e1c5dc --- /dev/null +++ b/vendor/_nuts/github.com/ogier/pflag/bool_test.go @@ -0,0 +1,164 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package pflag + +import ( + "bytes" + "fmt" + "strconv" + "testing" +) + +// This value can be a boolean ("true", "false") or "maybe" +type triStateValue int + +const ( + triStateFalse triStateValue = 0 + triStateTrue triStateValue = 1 + triStateMaybe triStateValue = 2 +) + +const strTriStateMaybe = "maybe" + +func (v *triStateValue) IsBoolFlag() bool { + return true +} + +func (v *triStateValue) Get() interface{} { + return triStateValue(*v) +} + +func (v *triStateValue) Set(s string) error { + if s == strTriStateMaybe { + *v = triStateMaybe + return nil + } + boolVal, err := strconv.ParseBool(s) + if boolVal { + *v = triStateTrue + } else { + *v = triStateFalse + } + return err +} + +func (v *triStateValue) String() string { + if *v == triStateMaybe { + return strTriStateMaybe + } + return fmt.Sprintf("%v", bool(*v == triStateTrue)) +} + +// The type of the flag as requred by the pflag.Value interface +func (v *triStateValue) Type() string { + return "version" +} + +func setUpFlagSet(tristate *triStateValue) *FlagSet { + f := NewFlagSet("test", ContinueOnError) + *tristate = triStateFalse + f.VarP(tristate, "tristate", "t", "tristate value (true, maybe or false)") + return f +} + +func TestExplicitTrue(t *testing.T) { + var tristate triStateValue + f := setUpFlagSet(&tristate) + err := f.Parse([]string{"--tristate=true"}) + if err != nil { + t.Fatal("expected no error; got", err) + } + if tristate != triStateTrue { + t.Fatal("expected", triStateTrue, "(triStateTrue) but got", tristate, "instead") + } +} + +func TestImplicitTrue(t *testing.T) { + var tristate triStateValue + f := setUpFlagSet(&tristate) + err := f.Parse([]string{"--tristate"}) + if err != nil { + t.Fatal("expected no error; got", err) + } + if tristate != triStateTrue { + t.Fatal("expected", triStateTrue, "(triStateTrue) but got", tristate, "instead") + } +} + +func TestShortFlag(t *testing.T) { + var tristate triStateValue + f := setUpFlagSet(&tristate) + err := f.Parse([]string{"-t"}) + if err != nil { + t.Fatal("expected no error; got", err) + } + if tristate != triStateTrue { + t.Fatal("expected", triStateTrue, "(triStateTrue) but got", tristate, "instead") + } +} + +func TestShortFlagExtraArgument(t *testing.T) { + var tristate triStateValue + f := setUpFlagSet(&tristate) + // The"maybe"turns into an arg, since short boolean options will only do true/false + err := f.Parse([]string{"-t", "maybe"}) + if err != nil { + t.Fatal("expected no error; got", err) + } + if tristate != triStateTrue { + t.Fatal("expected", triStateTrue, "(triStateTrue) but got", tristate, "instead") + } + args := f.Args() + if len(args) != 1 || args[0] != "maybe" { + t.Fatal("expected an extra 'maybe' argument to stick around") + } +} + +func TestExplicitMaybe(t *testing.T) { + var tristate triStateValue + f := setUpFlagSet(&tristate) + err := f.Parse([]string{"--tristate=maybe"}) + if err != nil { + t.Fatal("expected no error; got", err) + } + if tristate != triStateMaybe { + t.Fatal("expected", triStateMaybe, "(triStateMaybe) but got", tristate, "instead") + } +} + +func TestExplicitFalse(t *testing.T) { + var tristate triStateValue + f := setUpFlagSet(&tristate) + err := f.Parse([]string{"--tristate=false"}) + if err != nil { + t.Fatal("expected no error; got", err) + } + if tristate != triStateFalse { + t.Fatal("expected", triStateFalse, "(triStateFalse) but got", tristate, "instead") + } +} + +func TestImplicitFalse(t *testing.T) { + var tristate triStateValue + f := setUpFlagSet(&tristate) + err := f.Parse([]string{}) + if err != nil { + t.Fatal("expected no error; got", err) + } + if tristate != triStateFalse { + t.Fatal("expected", triStateFalse, "(triStateFalse) but got", tristate, "instead") + } +} + +func TestInvalidValue(t *testing.T) { + var tristate triStateValue + f := setUpFlagSet(&tristate) + var buf bytes.Buffer + f.SetOutput(&buf) + err := f.Parse([]string{"--tristate=invalid"}) + if err == nil { + t.Fatal("expected an error but did not get any, tristate has value", tristate) + } +} diff --git a/vendor/_nuts/github.com/ogier/pflag/duration.go b/vendor/_nuts/github.com/ogier/pflag/duration.go new file mode 100644 index 00000000..db594639 --- /dev/null +++ b/vendor/_nuts/github.com/ogier/pflag/duration.go @@ -0,0 +1,74 @@ +package pflag + +import "time" + +// -- time.Duration Value +type durationValue time.Duration + +func newDurationValue(val time.Duration, p *time.Duration) *durationValue { + *p = val + return (*durationValue)(p) +} + +func (d *durationValue) Set(s string) error { + v, err := time.ParseDuration(s) + *d = durationValue(v) + return err +} + +func (d *durationValue) String() string { return (*time.Duration)(d).String() } + +// Value is the interface to the dynamic value stored in a flag. +// (The default value is represented as a string.) +type Value interface { + String() string + Set(string) error +} + +// DurationVar defines a time.Duration flag with specified name, default value, and usage string. +// The argument p points to a time.Duration variable in which to store the value of the flag. +func (f *FlagSet) DurationVar(p *time.Duration, name string, value time.Duration, usage string) { + f.VarP(newDurationValue(value, p), name, "", usage) +} + +// Like DurationVar, but accepts a shorthand letter that can be used after a single dash. +func (f *FlagSet) DurationVarP(p *time.Duration, name, shorthand string, value time.Duration, usage string) { + f.VarP(newDurationValue(value, p), name, shorthand, usage) +} + +// DurationVar defines a time.Duration flag with specified name, default value, and usage string. +// The argument p points to a time.Duration variable in which to store the value of the flag. +func DurationVar(p *time.Duration, name string, value time.Duration, usage string) { + CommandLine.VarP(newDurationValue(value, p), name, "", usage) +} + +// Like DurationVar, but accepts a shorthand letter that can be used after a single dash. +func DurationVarP(p *time.Duration, name, shorthand string, value time.Duration, usage string) { + CommandLine.VarP(newDurationValue(value, p), name, shorthand, usage) +} + +// Duration defines a time.Duration flag with specified name, default value, and usage string. +// The return value is the address of a time.Duration variable that stores the value of the flag. +func (f *FlagSet) Duration(name string, value time.Duration, usage string) *time.Duration { + p := new(time.Duration) + f.DurationVarP(p, name, "", value, usage) + return p +} + +// Like Duration, but accepts a shorthand letter that can be used after a single dash. +func (f *FlagSet) DurationP(name, shorthand string, value time.Duration, usage string) *time.Duration { + p := new(time.Duration) + f.DurationVarP(p, name, shorthand, value, usage) + return p +} + +// Duration defines a time.Duration flag with specified name, default value, and usage string. +// The return value is the address of a time.Duration variable that stores the value of the flag. +func Duration(name string, value time.Duration, usage string) *time.Duration { + return CommandLine.DurationP(name, "", value, usage) +} + +// Like Duration, but accepts a shorthand letter that can be used after a single dash. +func DurationP(name, shorthand string, value time.Duration, usage string) *time.Duration { + return CommandLine.DurationP(name, shorthand, value, usage) +} diff --git a/.vendor/src/github.com/spf13/pflag/example_test.go b/vendor/_nuts/github.com/ogier/pflag/example_test.go similarity index 97% rename from .vendor/src/github.com/spf13/pflag/example_test.go rename to vendor/_nuts/github.com/ogier/pflag/example_test.go index 03ebeaad..54f91165 100644 --- a/.vendor/src/github.com/spf13/pflag/example_test.go +++ b/vendor/_nuts/github.com/ogier/pflag/example_test.go @@ -11,7 +11,7 @@ import ( "strings" "time" - flag "github.com/ogier/pflag" + flag "github.com/github/git-lfs/vendor/_nuts/github.com/ogier/pflag" ) // Example 1: A single string flag called "species" with default value "gopher". diff --git a/.vendor/src/github.com/spf13/pflag/export_test.go b/vendor/_nuts/github.com/ogier/pflag/export_test.go similarity index 100% rename from .vendor/src/github.com/spf13/pflag/export_test.go rename to vendor/_nuts/github.com/ogier/pflag/export_test.go diff --git a/vendor/_nuts/github.com/ogier/pflag/flag.go b/vendor/_nuts/github.com/ogier/pflag/flag.go new file mode 100644 index 00000000..f3830586 --- /dev/null +++ b/vendor/_nuts/github.com/ogier/pflag/flag.go @@ -0,0 +1,554 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +/* + pflag is a drop-in replacement for Go's flag package, implementing + POSIX/GNU-style --flags. + + pflag is compatible with the GNU extensions to the POSIX recommendations + for command-line options. See + http://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html + + Usage: + + pflag is a drop-in replacement of Go's native flag package. If you import + pflag under the name "flag" then all code should continue to function + with no changes. + + import flag "github.com/ogier/pflag" + + There is one exception to this: if you directly instantiate the Flag struct + there is one more field "Shorthand" that you will need to set. + Most code never instantiates this struct directly, and instead uses + functions such as String(), BoolVar(), and Var(), and is therefore + unaffected. + + Define flags using flag.String(), Bool(), Int(), etc. + + This declares an integer flag, -flagname, stored in the pointer ip, with type *int. + var ip = flag.Int("flagname", 1234, "help message for flagname") + If you like, you can bind the flag to a variable using the Var() functions. + var flagvar int + func init() { + flag.IntVar(&flagvar, "flagname", 1234, "help message for flagname") + } + Or you can create custom flags that satisfy the Value interface (with + pointer receivers) and couple them to flag parsing by + flag.Var(&flagVal, "name", "help message for flagname") + For such flags, the default value is just the initial value of the variable. + + After all flags are defined, call + flag.Parse() + to parse the command line into the defined flags. + + Flags may then be used directly. If you're using the flags themselves, + they are all pointers; if you bind to variables, they're values. + fmt.Println("ip has value ", *ip) + fmt.Println("flagvar has value ", flagvar) + + After parsing, the arguments after the flag are available as the + slice flag.Args() or individually as flag.Arg(i). + The arguments are indexed from 0 through flag.NArg()-1. + + The pflag package also defines some new functions that are not in flag, + that give one-letter shorthands for flags. You can use these by appending + 'P' to the name of any function that defines a flag. + var ip = flag.IntP("flagname", "f", 1234, "help message") + var flagvar bool + func init() { + flag.BoolVarP("boolname", "b", true, "help message") + } + flag.VarP(&flagVar, "varname", "v", 1234, "help message") + Shorthand letters can be used with single dashes on the command line. + Boolean shorthand flags can be combined with other shorthand flags. + + Command line flag syntax: + --flag // boolean flags only + --flag=x + + Unlike the flag package, a single dash before an option means something + different than a double dash. Single dashes signify a series of shorthand + letters for flags. All but the last shorthand letter must be boolean flags. + // boolean flags + -f + -abc + // non-boolean flags + -n 1234 + -Ifile + // mixed + -abcs "hello" + -abcn1234 + + Flag parsing stops after the terminator "--". Unlike the flag package, + flags can be interspersed with arguments anywhere on the command line + before this terminator. + + Integer flags accept 1234, 0664, 0x1234 and may be negative. + Boolean flags (in their long form) accept 1, 0, t, f, true, false, + TRUE, FALSE, True, False. + Duration flags accept any input valid for time.ParseDuration. + + The default set of command-line flags is controlled by + top-level functions. The FlagSet type allows one to define + independent sets of flags, such as to implement subcommands + in a command-line interface. The methods of FlagSet are + analogous to the top-level functions for the command-line + flag set. +*/ +package pflag + +import ( + "errors" + "fmt" + "io" + "os" + "sort" + "strings" +) + +// ErrHelp is the error returned if the flag -help is invoked but no such flag is defined. +var ErrHelp = errors.New("pflag: help requested") + +// ErrorHandling defines how to handle flag parsing errors. +type ErrorHandling int + +const ( + ContinueOnError ErrorHandling = iota + ExitOnError + PanicOnError +) + +// A FlagSet represents a set of defined flags. +type FlagSet struct { + // Usage is the function called when an error occurs while parsing flags. + // The field is a function (not a method) that may be changed to point to + // a custom error handler. + Usage func() + + name string + parsed bool + actual map[string]*Flag + formal map[string]*Flag + shorthands map[byte]*Flag + args []string // arguments after flags + exitOnError bool // does the program exit if there's an error? + errorHandling ErrorHandling + output io.Writer // nil means stderr; use out() accessor + interspersed bool // allow interspersed option/non-option args +} + +// A Flag represents the state of a flag. +type Flag struct { + Name string // name as it appears on command line + Shorthand string // one-letter abbreviated flag + Usage string // help message + Value Value // value as set + DefValue string // default value (as text); for usage message +} + +// sortFlags returns the flags as a slice in lexicographical sorted order. +func sortFlags(flags map[string]*Flag) []*Flag { + list := make(sort.StringSlice, len(flags)) + i := 0 + for _, f := range flags { + list[i] = f.Name + i++ + } + list.Sort() + result := make([]*Flag, len(list)) + for i, name := range list { + result[i] = flags[name] + } + return result +} + +func (f *FlagSet) out() io.Writer { + if f.output == nil { + return os.Stderr + } + return f.output +} + +// SetOutput sets the destination for usage and error messages. +// If output is nil, os.Stderr is used. +func (f *FlagSet) SetOutput(output io.Writer) { + f.output = output +} + +// VisitAll visits the flags in lexicographical order, calling fn for each. +// It visits all flags, even those not set. +func (f *FlagSet) VisitAll(fn func(*Flag)) { + for _, flag := range sortFlags(f.formal) { + fn(flag) + } +} + +// VisitAll visits the command-line flags in lexicographical order, calling +// fn for each. It visits all flags, even those not set. +func VisitAll(fn func(*Flag)) { + CommandLine.VisitAll(fn) +} + +// Visit visits the flags in lexicographical order, calling fn for each. +// It visits only those flags that have been set. +func (f *FlagSet) Visit(fn func(*Flag)) { + for _, flag := range sortFlags(f.actual) { + fn(flag) + } +} + +// Visit visits the command-line flags in lexicographical order, calling fn +// for each. It visits only those flags that have been set. +func Visit(fn func(*Flag)) { + CommandLine.Visit(fn) +} + +// Lookup returns the Flag structure of the named flag, returning nil if none exists. +func (f *FlagSet) Lookup(name string) *Flag { + return f.formal[name] +} + +// Lookup returns the Flag structure of the named command-line flag, +// returning nil if none exists. +func Lookup(name string) *Flag { + return CommandLine.formal[name] +} + +// Set sets the value of the named flag. +func (f *FlagSet) Set(name, value string) error { + flag, ok := f.formal[name] + if !ok { + return fmt.Errorf("no such flag -%v", name) + } + err := flag.Value.Set(value) + if err != nil { + return err + } + if f.actual == nil { + f.actual = make(map[string]*Flag) + } + f.actual[name] = flag + return nil +} + +// Set sets the value of the named command-line flag. +func Set(name, value string) error { + return CommandLine.Set(name, value) +} + +// PrintDefaults prints, to standard error unless configured +// otherwise, the default values of all defined flags in the set. +func (f *FlagSet) PrintDefaults() { + f.VisitAll(func(flag *Flag) { + format := "--%s=%s: %s\n" + if _, ok := flag.Value.(*stringValue); ok { + // put quotes on the value + format = "--%s=%q: %s\n" + } + if len(flag.Shorthand) > 0 { + format = " -%s, " + format + } else { + format = " %s " + format + } + fmt.Fprintf(f.out(), format, flag.Shorthand, flag.Name, flag.DefValue, flag.Usage) + }) +} + +// PrintDefaults prints to standard error the default values of all defined command-line flags. +func PrintDefaults() { + CommandLine.PrintDefaults() +} + +// defaultUsage is the default function to print a usage message. +func defaultUsage(f *FlagSet) { + fmt.Fprintf(f.out(), "Usage of %s:\n", f.name) + f.PrintDefaults() +} + +// NOTE: Usage is not just defaultUsage(CommandLine) +// because it serves (via godoc flag Usage) as the example +// for how to write your own usage function. + +// Usage prints to standard error a usage message documenting all defined command-line flags. +// The function is a variable that may be changed to point to a custom function. +var Usage = func() { + fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0]) + PrintDefaults() +} + +// NFlag returns the number of flags that have been set. +func (f *FlagSet) NFlag() int { return len(f.actual) } + +// NFlag returns the number of command-line flags that have been set. +func NFlag() int { return len(CommandLine.actual) } + +// Arg returns the i'th argument. Arg(0) is the first remaining argument +// after flags have been processed. +func (f *FlagSet) Arg(i int) string { + if i < 0 || i >= len(f.args) { + return "" + } + return f.args[i] +} + +// Arg returns the i'th command-line argument. Arg(0) is the first remaining argument +// after flags have been processed. +func Arg(i int) string { + return CommandLine.Arg(i) +} + +// NArg is the number of arguments remaining after flags have been processed. +func (f *FlagSet) NArg() int { return len(f.args) } + +// NArg is the number of arguments remaining after flags have been processed. +func NArg() int { return len(CommandLine.args) } + +// Args returns the non-flag arguments. +func (f *FlagSet) Args() []string { return f.args } + +// Args returns the non-flag command-line arguments. +func Args() []string { return CommandLine.args } + +// Var defines a flag with the specified name and usage string. The type and +// value of the flag are represented by the first argument, of type Value, which +// typically holds a user-defined implementation of Value. For instance, the +// caller could create a flag that turns a comma-separated string into a slice +// of strings by giving the slice the methods of Value; in particular, Set would +// decompose the comma-separated string into the slice. +func (f *FlagSet) Var(value Value, name string, usage string) { + f.VarP(value, name, "", usage) +} + +// Like Var, but accepts a shorthand letter that can be used after a single dash. +func (f *FlagSet) VarP(value Value, name, shorthand, usage string) { + // Remember the default value as a string; it won't change. + flag := &Flag{name, shorthand, usage, value, value.String()} + _, alreadythere := f.formal[name] + if alreadythere { + msg := fmt.Sprintf("%s flag redefined: %s", f.name, name) + fmt.Fprintln(f.out(), msg) + panic(msg) // Happens only if flags are declared with identical names + } + if f.formal == nil { + f.formal = make(map[string]*Flag) + } + f.formal[name] = flag + + if len(shorthand) == 0 { + return + } + if len(shorthand) > 1 { + fmt.Fprintf(f.out(), "%s shorthand more than ASCII character: %s\n", f.name, shorthand) + panic("shorthand is more than one character") + } + if f.shorthands == nil { + f.shorthands = make(map[byte]*Flag) + } + c := shorthand[0] + old, alreadythere := f.shorthands[c] + if alreadythere { + fmt.Fprintf(f.out(), "%s shorthand reused: %q for %s already used for %s\n", f.name, c, name, old.Name) + panic("shorthand redefinition") + } + f.shorthands[c] = flag +} + +// Var defines a flag with the specified name and usage string. The type and +// value of the flag are represented by the first argument, of type Value, which +// typically holds a user-defined implementation of Value. For instance, the +// caller could create a flag that turns a comma-separated string into a slice +// of strings by giving the slice the methods of Value; in particular, Set would +// decompose the comma-separated string into the slice. +func Var(value Value, name string, usage string) { + CommandLine.VarP(value, name, "", usage) +} + +// Like Var, but accepts a shorthand letter that can be used after a single dash. +func VarP(value Value, name, shorthand, usage string) { + CommandLine.VarP(value, name, shorthand, usage) +} + +// failf prints to standard error a formatted error and usage message and +// returns the error. +func (f *FlagSet) failf(format string, a ...interface{}) error { + err := fmt.Errorf(format, a...) + fmt.Fprintln(f.out(), err) + f.usage() + return err +} + +// usage calls the Usage method for the flag set, or the usage function if +// the flag set is CommandLine. +func (f *FlagSet) usage() { + if f == CommandLine { + Usage() + } else if f.Usage == nil { + defaultUsage(f) + } else { + f.Usage() + } +} + +func (f *FlagSet) setFlag(flag *Flag, value string, origArg string) error { + if err := flag.Value.Set(value); err != nil { + return f.failf("invalid argument %q for %s: %v", value, origArg, err) + } + // mark as visited for Visit() + if f.actual == nil { + f.actual = make(map[string]*Flag) + } + f.actual[flag.Name] = flag + + return nil +} + +func (f *FlagSet) parseArgs(args []string) error { + for len(args) > 0 { + s := args[0] + args = args[1:] + if len(s) == 0 || s[0] != '-' || len(s) == 1 { + if !f.interspersed { + f.args = append(f.args, s) + f.args = append(f.args, args...) + return nil + } + f.args = append(f.args, s) + continue + } + + if s[1] == '-' { + if len(s) == 2 { // "--" terminates the flags + f.args = append(f.args, args...) + return nil + } + name := s[2:] + if len(name) == 0 || name[0] == '-' || name[0] == '=' { + return f.failf("bad flag syntax: %s", s) + } + split := strings.SplitN(name, "=", 2) + name = split[0] + m := f.formal + flag, alreadythere := m[name] // BUG + if !alreadythere { + if name == "help" { // special case for nice help message. + f.usage() + return ErrHelp + } + return f.failf("unknown flag: --%s", name) + } + if len(split) == 1 { + if bv, ok := flag.Value.(boolFlag); !ok || !bv.IsBoolFlag() { + return f.failf("flag needs an argument: %s", s) + } + f.setFlag(flag, "true", s) + } else { + if err := f.setFlag(flag, split[1], s); err != nil { + return err + } + } + } else { + shorthands := s[1:] + for i := 0; i < len(shorthands); i++ { + c := shorthands[i] + flag, alreadythere := f.shorthands[c] + if !alreadythere { + if c == 'h' { // special case for nice help message. + f.usage() + return ErrHelp + } + return f.failf("unknown shorthand flag: %q in -%s", c, shorthands) + } + if bv, ok := flag.Value.(boolFlag); ok && bv.IsBoolFlag() { + f.setFlag(flag, "true", s) + continue + } + if i < len(shorthands)-1 { + if err := f.setFlag(flag, shorthands[i+1:], s); err != nil { + return err + } + break + } + if len(args) == 0 { + return f.failf("flag needs an argument: %q in -%s", c, shorthands) + } + if err := f.setFlag(flag, args[0], s); err != nil { + return err + } + args = args[1:] + break // should be unnecessary + } + } + } + return nil +} + +// Parse parses flag definitions from the argument list, which should not +// include the command name. Must be called after all flags in the FlagSet +// are defined and before flags are accessed by the program. +// The return value will be ErrHelp if -help was set but not defined. +func (f *FlagSet) Parse(arguments []string) error { + f.parsed = true + f.args = make([]string, 0, len(arguments)) + err := f.parseArgs(arguments) + if err != nil { + switch f.errorHandling { + case ContinueOnError: + return err + case ExitOnError: + os.Exit(2) + case PanicOnError: + panic(err) + } + } + return nil +} + +// Parsed reports whether f.Parse has been called. +func (f *FlagSet) Parsed() bool { + return f.parsed +} + +// Parse parses the command-line flags from os.Args[1:]. Must be called +// after all flags are defined and before flags are accessed by the program. +func Parse() { + // Ignore errors; CommandLine is set for ExitOnError. + CommandLine.Parse(os.Args[1:]) +} + +// Whether to support interspersed option/non-option arguments. +func SetInterspersed(interspersed bool) { + CommandLine.SetInterspersed(interspersed) +} + +// Parsed returns true if the command-line flags have been parsed. +func Parsed() bool { + return CommandLine.Parsed() +} + +// The default set of command-line flags, parsed from os.Args. +var CommandLine = NewFlagSet(os.Args[0], ExitOnError) + +// NewFlagSet returns a new, empty flag set with the specified name and +// error handling property. +func NewFlagSet(name string, errorHandling ErrorHandling) *FlagSet { + f := &FlagSet{ + name: name, + errorHandling: errorHandling, + interspersed: true, + } + return f +} + +// Whether to support interspersed option/non-option arguments. +func (f *FlagSet) SetInterspersed(interspersed bool) { + f.interspersed = interspersed +} + +// Init sets the name and error handling property for a flag set. +// By default, the zero FlagSet uses an empty name and the +// ContinueOnError error handling policy. +func (f *FlagSet) Init(name string, errorHandling ErrorHandling) { + f.name = name + f.errorHandling = errorHandling +} diff --git a/vendor/_nuts/github.com/ogier/pflag/flag_test.go b/vendor/_nuts/github.com/ogier/pflag/flag_test.go new file mode 100644 index 00000000..82f7fae7 --- /dev/null +++ b/vendor/_nuts/github.com/ogier/pflag/flag_test.go @@ -0,0 +1,350 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package pflag + +import ( + "bytes" + "fmt" + "os" + "sort" + "strings" + "testing" + "time" +) + +var ( + test_bool = Bool("test_bool", false, "bool value") + test_int = Int("test_int", 0, "int value") + test_int64 = Int64("test_int64", 0, "int64 value") + test_uint = Uint("test_uint", 0, "uint value") + test_uint64 = Uint64("test_uint64", 0, "uint64 value") + test_string = String("test_string", "0", "string value") + test_float64 = Float64("test_float64", 0, "float64 value") + test_duration = Duration("test_duration", 0, "time.Duration value") +) + +func boolString(s string) string { + if s == "0" { + return "false" + } + return "true" +} + +func TestEverything(t *testing.T) { + m := make(map[string]*Flag) + desired := "0" + visitor := func(f *Flag) { + if len(f.Name) > 5 && f.Name[0:5] == "test_" { + m[f.Name] = f + ok := false + switch { + case f.Value.String() == desired: + ok = true + case f.Name == "test_bool" && f.Value.String() == boolString(desired): + ok = true + case f.Name == "test_duration" && f.Value.String() == desired+"s": + ok = true + } + if !ok { + t.Error("Visit: bad value", f.Value.String(), "for", f.Name) + } + } + } + VisitAll(visitor) + if len(m) != 8 { + t.Error("VisitAll misses some flags") + for k, v := range m { + t.Log(k, *v) + } + } + m = make(map[string]*Flag) + Visit(visitor) + if len(m) != 0 { + t.Errorf("Visit sees unset flags") + for k, v := range m { + t.Log(k, *v) + } + } + // Now set all flags + Set("test_bool", "true") + Set("test_int", "1") + Set("test_int64", "1") + Set("test_uint", "1") + Set("test_uint64", "1") + Set("test_string", "1") + Set("test_float64", "1") + Set("test_duration", "1s") + desired = "1" + Visit(visitor) + if len(m) != 8 { + t.Error("Visit fails after set") + for k, v := range m { + t.Log(k, *v) + } + } + // Now test they're visited in sort order. + var flagNames []string + Visit(func(f *Flag) { flagNames = append(flagNames, f.Name) }) + if !sort.StringsAreSorted(flagNames) { + t.Errorf("flag names not sorted: %v", flagNames) + } +} + +func TestUsage(t *testing.T) { + called := false + ResetForTesting(func() { called = true }) + if GetCommandLine().Parse([]string{"--x"}) == nil { + t.Error("parse did not fail for unknown flag") + } + if !called { + t.Error("did not call Usage for unknown flag") + } +} + +func testParse(f *FlagSet, t *testing.T) { + if f.Parsed() { + t.Error("f.Parse() = true before Parse") + } + boolFlag := f.Bool("bool", false, "bool value") + bool2Flag := f.Bool("bool2", false, "bool2 value") + bool3Flag := f.Bool("bool3", false, "bool3 value") + intFlag := f.Int("int", 0, "int value") + int64Flag := f.Int64("int64", 0, "int64 value") + uintFlag := f.Uint("uint", 0, "uint value") + uint64Flag := f.Uint64("uint64", 0, "uint64 value") + stringFlag := f.String("string", "0", "string value") + float64Flag := f.Float64("float64", 0, "float64 value") + durationFlag := f.Duration("duration", 5*time.Second, "time.Duration value") + extra := "one-extra-argument" + args := []string{ + "--bool", + "--bool2=true", + "--bool3=false", + "--int=22", + "--int64=0x23", + "--uint=24", + "--uint64=25", + "--string=hello", + "--float64=2718e28", + "--duration=2m", + extra, + } + if err := f.Parse(args); err != nil { + t.Fatal(err) + } + if !f.Parsed() { + t.Error("f.Parse() = false after Parse") + } + if *boolFlag != true { + t.Error("bool flag should be true, is ", *boolFlag) + } + if *bool2Flag != true { + t.Error("bool2 flag should be true, is ", *bool2Flag) + } + if *bool3Flag != false { + t.Error("bool3 flag should be false, is ", *bool2Flag) + } + if *intFlag != 22 { + t.Error("int flag should be 22, is ", *intFlag) + } + if *int64Flag != 0x23 { + t.Error("int64 flag should be 0x23, is ", *int64Flag) + } + if *uintFlag != 24 { + t.Error("uint flag should be 24, is ", *uintFlag) + } + if *uint64Flag != 25 { + t.Error("uint64 flag should be 25, is ", *uint64Flag) + } + if *stringFlag != "hello" { + t.Error("string flag should be `hello`, is ", *stringFlag) + } + if *float64Flag != 2718e28 { + t.Error("float64 flag should be 2718e28, is ", *float64Flag) + } + if *durationFlag != 2*time.Minute { + t.Error("duration flag should be 2m, is ", *durationFlag) + } + if len(f.Args()) != 1 { + t.Error("expected one argument, got", len(f.Args())) + } else if f.Args()[0] != extra { + t.Errorf("expected argument %q got %q", extra, f.Args()[0]) + } +} + +func TestShorthand(t *testing.T) { + f := NewFlagSet("shorthand", ContinueOnError) + if f.Parsed() { + t.Error("f.Parse() = true before Parse") + } + boolaFlag := f.BoolP("boola", "a", false, "bool value") + boolbFlag := f.BoolP("boolb", "b", false, "bool2 value") + boolcFlag := f.BoolP("boolc", "c", false, "bool3 value") + stringFlag := f.StringP("string", "s", "0", "string value") + extra := "interspersed-argument" + notaflag := "--i-look-like-a-flag" + args := []string{ + "-ab", + extra, + "-cs", + "hello", + "--", + notaflag, + } + if err := f.Parse(args); err != nil { + t.Fatal(err) + } + if !f.Parsed() { + t.Error("f.Parse() = false after Parse") + } + if *boolaFlag != true { + t.Error("boola flag should be true, is ", *boolaFlag) + } + if *boolbFlag != true { + t.Error("boolb flag should be true, is ", *boolbFlag) + } + if *boolcFlag != true { + t.Error("boolc flag should be true, is ", *boolcFlag) + } + if *stringFlag != "hello" { + t.Error("string flag should be `hello`, is ", *stringFlag) + } + if len(f.Args()) != 2 { + t.Error("expected one argument, got", len(f.Args())) + } else if f.Args()[0] != extra { + t.Errorf("expected argument %q got %q", extra, f.Args()[0]) + } else if f.Args()[1] != notaflag { + t.Errorf("expected argument %q got %q", notaflag, f.Args()[1]) + } +} + +func TestParse(t *testing.T) { + ResetForTesting(func() { t.Error("bad parse") }) + testParse(GetCommandLine(), t) +} + +func TestFlagSetParse(t *testing.T) { + testParse(NewFlagSet("test", ContinueOnError), t) +} + +// Declare a user-defined flag type. +type flagVar []string + +func (f *flagVar) String() string { + return fmt.Sprint([]string(*f)) +} + +func (f *flagVar) Set(value string) error { + *f = append(*f, value) + return nil +} + +func TestUserDefined(t *testing.T) { + var flags FlagSet + flags.Init("test", ContinueOnError) + var v flagVar + flags.VarP(&v, "v", "v", "usage") + if err := flags.Parse([]string{"--v=1", "-v2", "-v", "3"}); err != nil { + t.Error(err) + } + if len(v) != 3 { + t.Fatal("expected 3 args; got ", len(v)) + } + expect := "[1 2 3]" + if v.String() != expect { + t.Errorf("expected value %q got %q", expect, v.String()) + } +} + +func TestSetOutput(t *testing.T) { + var flags FlagSet + var buf bytes.Buffer + flags.SetOutput(&buf) + flags.Init("test", ContinueOnError) + flags.Parse([]string{"--unknown"}) + if out := buf.String(); !strings.Contains(out, "--unknown") { + t.Logf("expected output mentioning unknown; got %q", out) + } +} + +// This tests that one can reset the flags. This still works but not well, and is +// superseded by FlagSet. +func TestChangingArgs(t *testing.T) { + ResetForTesting(func() { t.Fatal("bad parse") }) + oldArgs := os.Args + defer func() { os.Args = oldArgs }() + os.Args = []string{"cmd", "--before", "subcmd"} + before := Bool("before", false, "") + if err := GetCommandLine().Parse(os.Args[1:]); err != nil { + t.Fatal(err) + } + cmd := Arg(0) + os.Args = []string{"subcmd", "--after", "args"} + after := Bool("after", false, "") + Parse() + args := Args() + + if !*before || cmd != "subcmd" || !*after || len(args) != 1 || args[0] != "args" { + t.Fatalf("expected true subcmd true [args] got %v %v %v %v", *before, cmd, *after, args) + } +} + +// Test that -help invokes the usage message and returns ErrHelp. +func TestHelp(t *testing.T) { + var helpCalled = false + fs := NewFlagSet("help test", ContinueOnError) + fs.Usage = func() { helpCalled = true } + var flag bool + fs.BoolVar(&flag, "flag", false, "regular flag") + // Regular flag invocation should work + err := fs.Parse([]string{"--flag=true"}) + if err != nil { + t.Fatal("expected no error; got ", err) + } + if !flag { + t.Error("flag was not set by --flag") + } + if helpCalled { + t.Error("help called for regular flag") + helpCalled = false // reset for next test + } + // Help flag should work as expected. + err = fs.Parse([]string{"--help"}) + if err == nil { + t.Fatal("error expected") + } + if err != ErrHelp { + t.Fatal("expected ErrHelp; got ", err) + } + if !helpCalled { + t.Fatal("help was not called") + } + // If we define a help flag, that should override. + var help bool + fs.BoolVar(&help, "help", false, "help flag") + helpCalled = false + err = fs.Parse([]string{"--help"}) + if err != nil { + t.Fatal("expected no error for defined --help; got ", err) + } + if helpCalled { + t.Fatal("help was called; should not have been for defined help flag") + } +} + +func TestNoInterspersed(t *testing.T) { + f := NewFlagSet("test", ContinueOnError) + f.SetInterspersed(false) + f.Bool("true", true, "always true") + f.Bool("false", false, "always false") + err := f.Parse([]string{"--true", "break", "--false"}) + if err != nil { + t.Fatal("expected no error; got ", err) + } + args := f.Args() + if len(args) != 2 || args[0] != "break" || args[1] != "--false" { + t.Fatal("expected interspersed options/non-options to fail") + } +} diff --git a/vendor/_nuts/github.com/ogier/pflag/float32.go b/vendor/_nuts/github.com/ogier/pflag/float32.go new file mode 100644 index 00000000..a0041e25 --- /dev/null +++ b/vendor/_nuts/github.com/ogier/pflag/float32.go @@ -0,0 +1,70 @@ +package pflag + +import ( + "fmt" + "strconv" +) + +// -- float32 Value +type float32Value float32 + +func newFloat32Value(val float32, p *float32) *float32Value { + *p = val + return (*float32Value)(p) +} + +func (f *float32Value) Set(s string) error { + v, err := strconv.ParseFloat(s, 32) + *f = float32Value(v) + return err +} + +func (f *float32Value) String() string { return fmt.Sprintf("%v", *f) } + +// Float32Var defines a float32 flag with specified name, default value, and usage string. +// The argument p points to a float32 variable in which to store the value of the flag. +func (f *FlagSet) Float32Var(p *float32, name string, value float32, usage string) { + f.VarP(newFloat32Value(value, p), name, "", usage) +} + +// Like Float32Var, but accepts a shorthand letter that can be used after a single dash. +func (f *FlagSet) Float32VarP(p *float32, name, shorthand string, value float32, usage string) { + f.VarP(newFloat32Value(value, p), name, shorthand, usage) +} + +// Float32Var defines a float32 flag with specified name, default value, and usage string. +// The argument p points to a float32 variable in which to store the value of the flag. +func Float32Var(p *float32, name string, value float32, usage string) { + CommandLine.VarP(newFloat32Value(value, p), name, "", usage) +} + +// Like Float32Var, but accepts a shorthand letter that can be used after a single dash. +func Float32VarP(p *float32, name, shorthand string, value float32, usage string) { + CommandLine.VarP(newFloat32Value(value, p), name, shorthand, usage) +} + +// Float32 defines a float32 flag with specified name, default value, and usage string. +// The return value is the address of a float32 variable that stores the value of the flag. +func (f *FlagSet) Float32(name string, value float32, usage string) *float32 { + p := new(float32) + f.Float32VarP(p, name, "", value, usage) + return p +} + +// Like Float32, but accepts a shorthand letter that can be used after a single dash. +func (f *FlagSet) Float32P(name, shorthand string, value float32, usage string) *float32 { + p := new(float32) + f.Float32VarP(p, name, shorthand, value, usage) + return p +} + +// Float32 defines a float32 flag with specified name, default value, and usage string. +// The return value is the address of a float32 variable that stores the value of the flag. +func Float32(name string, value float32, usage string) *float32 { + return CommandLine.Float32P(name, "", value, usage) +} + +// Like Float32, but accepts a shorthand letter that can be used after a single dash. +func Float32P(name, shorthand string, value float32, usage string) *float32 { + return CommandLine.Float32P(name, shorthand, value, usage) +} diff --git a/vendor/_nuts/github.com/ogier/pflag/float64.go b/vendor/_nuts/github.com/ogier/pflag/float64.go new file mode 100644 index 00000000..8d79be06 --- /dev/null +++ b/vendor/_nuts/github.com/ogier/pflag/float64.go @@ -0,0 +1,70 @@ +package pflag + +import ( + "fmt" + "strconv" +) + +// -- float64 Value +type float64Value float64 + +func newFloat64Value(val float64, p *float64) *float64Value { + *p = val + return (*float64Value)(p) +} + +func (f *float64Value) Set(s string) error { + v, err := strconv.ParseFloat(s, 64) + *f = float64Value(v) + return err +} + +func (f *float64Value) String() string { return fmt.Sprintf("%v", *f) } + +// Float64Var defines a float64 flag with specified name, default value, and usage string. +// The argument p points to a float64 variable in which to store the value of the flag. +func (f *FlagSet) Float64Var(p *float64, name string, value float64, usage string) { + f.VarP(newFloat64Value(value, p), name, "", usage) +} + +// Like Float64Var, but accepts a shorthand letter that can be used after a single dash. +func (f *FlagSet) Float64VarP(p *float64, name, shorthand string, value float64, usage string) { + f.VarP(newFloat64Value(value, p), name, shorthand, usage) +} + +// Float64Var defines a float64 flag with specified name, default value, and usage string. +// The argument p points to a float64 variable in which to store the value of the flag. +func Float64Var(p *float64, name string, value float64, usage string) { + CommandLine.VarP(newFloat64Value(value, p), name, "", usage) +} + +// Like Float64Var, but accepts a shorthand letter that can be used after a single dash. +func Float64VarP(p *float64, name, shorthand string, value float64, usage string) { + CommandLine.VarP(newFloat64Value(value, p), name, shorthand, usage) +} + +// Float64 defines a float64 flag with specified name, default value, and usage string. +// The return value is the address of a float64 variable that stores the value of the flag. +func (f *FlagSet) Float64(name string, value float64, usage string) *float64 { + p := new(float64) + f.Float64VarP(p, name, "", value, usage) + return p +} + +// Like Float64, but accepts a shorthand letter that can be used after a single dash. +func (f *FlagSet) Float64P(name, shorthand string, value float64, usage string) *float64 { + p := new(float64) + f.Float64VarP(p, name, shorthand, value, usage) + return p +} + +// Float64 defines a float64 flag with specified name, default value, and usage string. +// The return value is the address of a float64 variable that stores the value of the flag. +func Float64(name string, value float64, usage string) *float64 { + return CommandLine.Float64P(name, "", value, usage) +} + +// Like Float64, but accepts a shorthand letter that can be used after a single dash. +func Float64P(name, shorthand string, value float64, usage string) *float64 { + return CommandLine.Float64P(name, shorthand, value, usage) +} diff --git a/vendor/_nuts/github.com/ogier/pflag/int.go b/vendor/_nuts/github.com/ogier/pflag/int.go new file mode 100644 index 00000000..cb85e149 --- /dev/null +++ b/vendor/_nuts/github.com/ogier/pflag/int.go @@ -0,0 +1,70 @@ +package pflag + +import ( + "fmt" + "strconv" +) + +// -- int Value +type intValue int + +func newIntValue(val int, p *int) *intValue { + *p = val + return (*intValue)(p) +} + +func (i *intValue) Set(s string) error { + v, err := strconv.ParseInt(s, 0, 64) + *i = intValue(v) + return err +} + +func (i *intValue) String() string { return fmt.Sprintf("%v", *i) } + +// IntVar defines an int flag with specified name, default value, and usage string. +// The argument p points to an int variable in which to store the value of the flag. +func (f *FlagSet) IntVar(p *int, name string, value int, usage string) { + f.VarP(newIntValue(value, p), name, "", usage) +} + +// Like IntVar, but accepts a shorthand letter that can be used after a single dash. +func (f *FlagSet) IntVarP(p *int, name, shorthand string, value int, usage string) { + f.VarP(newIntValue(value, p), name, shorthand, usage) +} + +// IntVar defines an int flag with specified name, default value, and usage string. +// The argument p points to an int variable in which to store the value of the flag. +func IntVar(p *int, name string, value int, usage string) { + CommandLine.VarP(newIntValue(value, p), name, "", usage) +} + +// Like IntVar, but accepts a shorthand letter that can be used after a single dash. +func IntVarP(p *int, name, shorthand string, value int, usage string) { + CommandLine.VarP(newIntValue(value, p), name, shorthand, usage) +} + +// Int defines an int flag with specified name, default value, and usage string. +// The return value is the address of an int variable that stores the value of the flag. +func (f *FlagSet) Int(name string, value int, usage string) *int { + p := new(int) + f.IntVarP(p, name, "", value, usage) + return p +} + +// Like Int, but accepts a shorthand letter that can be used after a single dash. +func (f *FlagSet) IntP(name, shorthand string, value int, usage string) *int { + p := new(int) + f.IntVarP(p, name, shorthand, value, usage) + return p +} + +// Int defines an int flag with specified name, default value, and usage string. +// The return value is the address of an int variable that stores the value of the flag. +func Int(name string, value int, usage string) *int { + return CommandLine.IntP(name, "", value, usage) +} + +// Like Int, but accepts a shorthand letter that can be used after a single dash. +func IntP(name, shorthand string, value int, usage string) *int { + return CommandLine.IntP(name, shorthand, value, usage) +} diff --git a/vendor/_nuts/github.com/ogier/pflag/int32.go b/vendor/_nuts/github.com/ogier/pflag/int32.go new file mode 100644 index 00000000..2e1a317f --- /dev/null +++ b/vendor/_nuts/github.com/ogier/pflag/int32.go @@ -0,0 +1,70 @@ +package pflag + +import ( + "fmt" + "strconv" +) + +// -- int32 Value +type int32Value int32 + +func newInt32Value(val int32, p *int32) *int32Value { + *p = val + return (*int32Value)(p) +} + +func (i *int32Value) Set(s string) error { + v, err := strconv.ParseInt(s, 0, 32) + *i = int32Value(v) + return err +} + +func (i *int32Value) String() string { return fmt.Sprintf("%v", *i) } + +// Int32Var defines an int32 flag with specified name, default value, and usage string. +// The argument p points to an int32 variable in which to store the value of the flag. +func (f *FlagSet) Int32Var(p *int32, name string, value int32, usage string) { + f.VarP(newInt32Value(value, p), name, "", usage) +} + +// Like Int32Var, but accepts a shorthand letter that can be used after a single dash. +func (f *FlagSet) Int32VarP(p *int32, name, shorthand string, value int32, usage string) { + f.VarP(newInt32Value(value, p), name, shorthand, usage) +} + +// Int32Var defines an int32 flag with specified name, default value, and usage string. +// The argument p points to an int32 variable in which to store the value of the flag. +func Int32Var(p *int32, name string, value int32, usage string) { + CommandLine.VarP(newInt32Value(value, p), name, "", usage) +} + +// Like Int32Var, but accepts a shorthand letter that can be used after a single dash. +func Int32VarP(p *int32, name, shorthand string, value int32, usage string) { + CommandLine.VarP(newInt32Value(value, p), name, shorthand, usage) +} + +// Int32 defines an int32 flag with specified name, default value, and usage string. +// The return value is the address of an int32 variable that stores the value of the flag. +func (f *FlagSet) Int32(name string, value int32, usage string) *int32 { + p := new(int32) + f.Int32VarP(p, name, "", value, usage) + return p +} + +// Like Int32, but accepts a shorthand letter that can be used after a single dash. +func (f *FlagSet) Int32P(name, shorthand string, value int32, usage string) *int32 { + p := new(int32) + f.Int32VarP(p, name, shorthand, value, usage) + return p +} + +// Int32 defines an int32 flag with specified name, default value, and usage string. +// The return value is the address of an int32 variable that stores the value of the flag. +func Int32(name string, value int32, usage string) *int32 { + return CommandLine.Int32P(name, "", value, usage) +} + +// Like Int32, but accepts a shorthand letter that can be used after a single dash. +func Int32P(name, shorthand string, value int32, usage string) *int32 { + return CommandLine.Int32P(name, shorthand, value, usage) +} diff --git a/vendor/_nuts/github.com/ogier/pflag/int64.go b/vendor/_nuts/github.com/ogier/pflag/int64.go new file mode 100644 index 00000000..43aeced8 --- /dev/null +++ b/vendor/_nuts/github.com/ogier/pflag/int64.go @@ -0,0 +1,70 @@ +package pflag + +import ( + "fmt" + "strconv" +) + +// -- int64 Value +type int64Value int64 + +func newInt64Value(val int64, p *int64) *int64Value { + *p = val + return (*int64Value)(p) +} + +func (i *int64Value) Set(s string) error { + v, err := strconv.ParseInt(s, 0, 64) + *i = int64Value(v) + return err +} + +func (i *int64Value) String() string { return fmt.Sprintf("%v", *i) } + +// Int64Var defines an int64 flag with specified name, default value, and usage string. +// The argument p points to an int64 variable in which to store the value of the flag. +func (f *FlagSet) Int64Var(p *int64, name string, value int64, usage string) { + f.VarP(newInt64Value(value, p), name, "", usage) +} + +// Like Int64Var, but accepts a shorthand letter that can be used after a single dash. +func (f *FlagSet) Int64VarP(p *int64, name, shorthand string, value int64, usage string) { + f.VarP(newInt64Value(value, p), name, shorthand, usage) +} + +// Int64Var defines an int64 flag with specified name, default value, and usage string. +// The argument p points to an int64 variable in which to store the value of the flag. +func Int64Var(p *int64, name string, value int64, usage string) { + CommandLine.VarP(newInt64Value(value, p), name, "", usage) +} + +// Like Int64Var, but accepts a shorthand letter that can be used after a single dash. +func Int64VarP(p *int64, name, shorthand string, value int64, usage string) { + CommandLine.VarP(newInt64Value(value, p), name, shorthand, usage) +} + +// Int64 defines an int64 flag with specified name, default value, and usage string. +// The return value is the address of an int64 variable that stores the value of the flag. +func (f *FlagSet) Int64(name string, value int64, usage string) *int64 { + p := new(int64) + f.Int64VarP(p, name, "", value, usage) + return p +} + +// Like Int64, but accepts a shorthand letter that can be used after a single dash. +func (f *FlagSet) Int64P(name, shorthand string, value int64, usage string) *int64 { + p := new(int64) + f.Int64VarP(p, name, shorthand, value, usage) + return p +} + +// Int64 defines an int64 flag with specified name, default value, and usage string. +// The return value is the address of an int64 variable that stores the value of the flag. +func Int64(name string, value int64, usage string) *int64 { + return CommandLine.Int64P(name, "", value, usage) +} + +// Like Int64, but accepts a shorthand letter that can be used after a single dash. +func Int64P(name, shorthand string, value int64, usage string) *int64 { + return CommandLine.Int64P(name, shorthand, value, usage) +} diff --git a/vendor/_nuts/github.com/ogier/pflag/int8.go b/vendor/_nuts/github.com/ogier/pflag/int8.go new file mode 100644 index 00000000..539c4eb3 --- /dev/null +++ b/vendor/_nuts/github.com/ogier/pflag/int8.go @@ -0,0 +1,70 @@ +package pflag + +import ( + "fmt" + "strconv" +) + +// -- int8 Value +type int8Value int8 + +func newInt8Value(val int8, p *int8) *int8Value { + *p = val + return (*int8Value)(p) +} + +func (i *int8Value) Set(s string) error { + v, err := strconv.ParseInt(s, 0, 8) + *i = int8Value(v) + return err +} + +func (i *int8Value) String() string { return fmt.Sprintf("%v", *i) } + +// Int8Var defines an int8 flag with specified name, default value, and usage string. +// The argument p points to an int8 variable in which to store the value of the flag. +func (f *FlagSet) Int8Var(p *int8, name string, value int8, usage string) { + f.VarP(newInt8Value(value, p), name, "", usage) +} + +// Like Int8Var, but accepts a shorthand letter that can be used after a single dash. +func (f *FlagSet) Int8VarP(p *int8, name, shorthand string, value int8, usage string) { + f.VarP(newInt8Value(value, p), name, shorthand, usage) +} + +// Int8Var defines an int8 flag with specified name, default value, and usage string. +// The argument p points to an int8 variable in which to store the value of the flag. +func Int8Var(p *int8, name string, value int8, usage string) { + CommandLine.VarP(newInt8Value(value, p), name, "", usage) +} + +// Like Int8Var, but accepts a shorthand letter that can be used after a single dash. +func Int8VarP(p *int8, name, shorthand string, value int8, usage string) { + CommandLine.VarP(newInt8Value(value, p), name, shorthand, usage) +} + +// Int8 defines an int8 flag with specified name, default value, and usage string. +// The return value is the address of an int8 variable that stores the value of the flag. +func (f *FlagSet) Int8(name string, value int8, usage string) *int8 { + p := new(int8) + f.Int8VarP(p, name, "", value, usage) + return p +} + +// Like Int8, but accepts a shorthand letter that can be used after a single dash. +func (f *FlagSet) Int8P(name, shorthand string, value int8, usage string) *int8 { + p := new(int8) + f.Int8VarP(p, name, shorthand, value, usage) + return p +} + +// Int8 defines an int8 flag with specified name, default value, and usage string. +// The return value is the address of an int8 variable that stores the value of the flag. +func Int8(name string, value int8, usage string) *int8 { + return CommandLine.Int8P(name, "", value, usage) +} + +// Like Int8, but accepts a shorthand letter that can be used after a single dash. +func Int8P(name, shorthand string, value int8, usage string) *int8 { + return CommandLine.Int8P(name, shorthand, value, usage) +} diff --git a/vendor/_nuts/github.com/ogier/pflag/ip.go b/vendor/_nuts/github.com/ogier/pflag/ip.go new file mode 100644 index 00000000..3a411fcd --- /dev/null +++ b/vendor/_nuts/github.com/ogier/pflag/ip.go @@ -0,0 +1,75 @@ +package pflag + +import ( + "fmt" + "net" +) + +// -- net.IP value +type ipValue net.IP + +func newIPValue(val net.IP, p *net.IP) *ipValue { + *p = val + return (*ipValue)(p) +} + +func (i *ipValue) String() string { return net.IP(*i).String() } +func (i *ipValue) Set(s string) error { + ip := net.ParseIP(s) + if ip == nil { + return fmt.Errorf("failed to parse IP: %q", s) + } + *i = ipValue(ip) + return nil +} +func (i *ipValue) Get() interface{} { + return net.IP(*i) +} + +// IPVar defines an net.IP flag with specified name, default value, and usage string. +// The argument p points to an net.IP variable in which to store the value of the flag. +func (f *FlagSet) IPVar(p *net.IP, name string, value net.IP, usage string) { + f.VarP(newIPValue(value, p), name, "", usage) +} + +// Like IPVar, but accepts a shorthand letter that can be used after a single dash. +func (f *FlagSet) IPVarP(p *net.IP, name, shorthand string, value net.IP, usage string) { + f.VarP(newIPValue(value, p), name, shorthand, usage) +} + +// IPVar defines an net.IP flag with specified name, default value, and usage string. +// The argument p points to an net.IP variable in which to store the value of the flag. +func IPVar(p *net.IP, name string, value net.IP, usage string) { + CommandLine.VarP(newIPValue(value, p), name, "", usage) +} + +// Like IPVar, but accepts a shorthand letter that can be used after a single dash. +func IPVarP(p *net.IP, name, shorthand string, value net.IP, usage string) { + CommandLine.VarP(newIPValue(value, p), name, shorthand, usage) +} + +// IP defines an net.IP flag with specified name, default value, and usage string. +// The return value is the address of an net.IP variable that stores the value of the flag. +func (f *FlagSet) IP(name string, value net.IP, usage string) *net.IP { + p := new(net.IP) + f.IPVarP(p, name, "", value, usage) + return p +} + +// Like IP, but accepts a shorthand letter that can be used after a single dash. +func (f *FlagSet) IPP(name, shorthand string, value net.IP, usage string) *net.IP { + p := new(net.IP) + f.IPVarP(p, name, shorthand, value, usage) + return p +} + +// IP defines an net.IP flag with specified name, default value, and usage string. +// The return value is the address of an net.IP variable that stores the value of the flag. +func IP(name string, value net.IP, usage string) *net.IP { + return CommandLine.IPP(name, "", value, usage) +} + +// Like IP, but accepts a shorthand letter that can be used after a single dash. +func IPP(name, shorthand string, value net.IP, usage string) *net.IP { + return CommandLine.IPP(name, shorthand, value, usage) +} diff --git a/vendor/_nuts/github.com/ogier/pflag/ipmask.go b/vendor/_nuts/github.com/ogier/pflag/ipmask.go new file mode 100644 index 00000000..b8a164ae --- /dev/null +++ b/vendor/_nuts/github.com/ogier/pflag/ipmask.go @@ -0,0 +1,85 @@ +package pflag + +import ( + "fmt" + "net" +) + +// -- net.IPMask value +type ipMaskValue net.IPMask + +func newIPMaskValue(val net.IPMask, p *net.IPMask) *ipMaskValue { + *p = val + return (*ipMaskValue)(p) +} + +func (i *ipMaskValue) String() string { return net.IPMask(*i).String() } +func (i *ipMaskValue) Set(s string) error { + ip := ParseIPv4Mask(s) + if ip == nil { + return fmt.Errorf("failed to parse IP mask: %q", s) + } + *i = ipMaskValue(ip) + return nil +} +func (i *ipMaskValue) Get() interface{} { + return net.IPMask(*i) +} + +// Parse IPv4 netmask written in IP form (e.g. 255.255.255.0). +// This function should really belong to the net package. +func ParseIPv4Mask(s string) net.IPMask { + mask := net.ParseIP(s) + if mask == nil { + return nil + } + return net.IPv4Mask(mask[12], mask[13], mask[14], mask[15]) +} + +// IPMaskVar defines an net.IPMask flag with specified name, default value, and usage string. +// The argument p points to an net.IPMask variable in which to store the value of the flag. +func (f *FlagSet) IPMaskVar(p *net.IPMask, name string, value net.IPMask, usage string) { + f.VarP(newIPMaskValue(value, p), name, "", usage) +} + +// Like IPMaskVar, but accepts a shorthand letter that can be used after a single dash. +func (f *FlagSet) IPMaskVarP(p *net.IPMask, name, shorthand string, value net.IPMask, usage string) { + f.VarP(newIPMaskValue(value, p), name, shorthand, usage) +} + +// IPMaskVar defines an net.IPMask flag with specified name, default value, and usage string. +// The argument p points to an net.IPMask variable in which to store the value of the flag. +func IPMaskVar(p *net.IPMask, name string, value net.IPMask, usage string) { + CommandLine.VarP(newIPMaskValue(value, p), name, "", usage) +} + +// Like IPMaskVar, but accepts a shorthand letter that can be used after a single dash. +func IPMaskVarP(p *net.IPMask, name, shorthand string, value net.IPMask, usage string) { + CommandLine.VarP(newIPMaskValue(value, p), name, shorthand, usage) +} + +// IPMask defines an net.IPMask flag with specified name, default value, and usage string. +// The return value is the address of an net.IPMask variable that stores the value of the flag. +func (f *FlagSet) IPMask(name string, value net.IPMask, usage string) *net.IPMask { + p := new(net.IPMask) + f.IPMaskVarP(p, name, "", value, usage) + return p +} + +// Like IPMask, but accepts a shorthand letter that can be used after a single dash. +func (f *FlagSet) IPMaskP(name, shorthand string, value net.IPMask, usage string) *net.IPMask { + p := new(net.IPMask) + f.IPMaskVarP(p, name, shorthand, value, usage) + return p +} + +// IPMask defines an net.IPMask flag with specified name, default value, and usage string. +// The return value is the address of an net.IPMask variable that stores the value of the flag. +func IPMask(name string, value net.IPMask, usage string) *net.IPMask { + return CommandLine.IPMaskP(name, "", value, usage) +} + +// Like IP, but accepts a shorthand letter that can be used after a single dash. +func IPMaskP(name, shorthand string, value net.IPMask, usage string) *net.IPMask { + return CommandLine.IPMaskP(name, shorthand, value, usage) +} diff --git a/vendor/_nuts/github.com/ogier/pflag/string.go b/vendor/_nuts/github.com/ogier/pflag/string.go new file mode 100644 index 00000000..65c0cb74 --- /dev/null +++ b/vendor/_nuts/github.com/ogier/pflag/string.go @@ -0,0 +1,66 @@ +package pflag + +import "fmt" + +// -- string Value +type stringValue string + +func newStringValue(val string, p *string) *stringValue { + *p = val + return (*stringValue)(p) +} + +func (s *stringValue) Set(val string) error { + *s = stringValue(val) + return nil +} + +func (s *stringValue) String() string { return fmt.Sprintf("%s", *s) } + +// StringVar defines a string flag with specified name, default value, and usage string. +// The argument p points to a string variable in which to store the value of the flag. +func (f *FlagSet) StringVar(p *string, name string, value string, usage string) { + f.VarP(newStringValue(value, p), name, "", usage) +} + +// Like StringVar, but accepts a shorthand letter that can be used after a single dash. +func (f *FlagSet) StringVarP(p *string, name, shorthand string, value string, usage string) { + f.VarP(newStringValue(value, p), name, shorthand, usage) +} + +// StringVar defines a string flag with specified name, default value, and usage string. +// The argument p points to a string variable in which to store the value of the flag. +func StringVar(p *string, name string, value string, usage string) { + CommandLine.VarP(newStringValue(value, p), name, "", usage) +} + +// Like StringVar, but accepts a shorthand letter that can be used after a single dash. +func StringVarP(p *string, name, shorthand string, value string, usage string) { + CommandLine.VarP(newStringValue(value, p), name, shorthand, usage) +} + +// String defines a string flag with specified name, default value, and usage string. +// The return value is the address of a string variable that stores the value of the flag. +func (f *FlagSet) String(name string, value string, usage string) *string { + p := new(string) + f.StringVarP(p, name, "", value, usage) + return p +} + +// Like String, but accepts a shorthand letter that can be used after a single dash. +func (f *FlagSet) StringP(name, shorthand string, value string, usage string) *string { + p := new(string) + f.StringVarP(p, name, shorthand, value, usage) + return p +} + +// String defines a string flag with specified name, default value, and usage string. +// The return value is the address of a string variable that stores the value of the flag. +func String(name string, value string, usage string) *string { + return CommandLine.StringP(name, "", value, usage) +} + +// Like String, but accepts a shorthand letter that can be used after a single dash. +func StringP(name, shorthand string, value string, usage string) *string { + return CommandLine.StringP(name, shorthand, value, usage) +} diff --git a/vendor/_nuts/github.com/ogier/pflag/uint.go b/vendor/_nuts/github.com/ogier/pflag/uint.go new file mode 100644 index 00000000..40b9ebbe --- /dev/null +++ b/vendor/_nuts/github.com/ogier/pflag/uint.go @@ -0,0 +1,70 @@ +package pflag + +import ( + "fmt" + "strconv" +) + +// -- uint Value +type uintValue uint + +func newUintValue(val uint, p *uint) *uintValue { + *p = val + return (*uintValue)(p) +} + +func (i *uintValue) Set(s string) error { + v, err := strconv.ParseUint(s, 0, 64) + *i = uintValue(v) + return err +} + +func (i *uintValue) String() string { return fmt.Sprintf("%v", *i) } + +// UintVar defines a uint flag with specified name, default value, and usage string. +// The argument p points to a uint variable in which to store the value of the flag. +func (f *FlagSet) UintVar(p *uint, name string, value uint, usage string) { + f.VarP(newUintValue(value, p), name, "", usage) +} + +// Like UintVar, but accepts a shorthand letter that can be used after a single dash. +func (f *FlagSet) UintVarP(p *uint, name, shorthand string, value uint, usage string) { + f.VarP(newUintValue(value, p), name, shorthand, usage) +} + +// UintVar defines a uint flag with specified name, default value, and usage string. +// The argument p points to a uint variable in which to store the value of the flag. +func UintVar(p *uint, name string, value uint, usage string) { + CommandLine.VarP(newUintValue(value, p), name, "", usage) +} + +// Like UintVar, but accepts a shorthand letter that can be used after a single dash. +func UintVarP(p *uint, name, shorthand string, value uint, usage string) { + CommandLine.VarP(newUintValue(value, p), name, shorthand, usage) +} + +// Uint defines a uint flag with specified name, default value, and usage string. +// The return value is the address of a uint variable that stores the value of the flag. +func (f *FlagSet) Uint(name string, value uint, usage string) *uint { + p := new(uint) + f.UintVarP(p, name, "", value, usage) + return p +} + +// Like Uint, but accepts a shorthand letter that can be used after a single dash. +func (f *FlagSet) UintP(name, shorthand string, value uint, usage string) *uint { + p := new(uint) + f.UintVarP(p, name, shorthand, value, usage) + return p +} + +// Uint defines a uint flag with specified name, default value, and usage string. +// The return value is the address of a uint variable that stores the value of the flag. +func Uint(name string, value uint, usage string) *uint { + return CommandLine.UintP(name, "", value, usage) +} + +// Like Uint, but accepts a shorthand letter that can be used after a single dash. +func UintP(name, shorthand string, value uint, usage string) *uint { + return CommandLine.UintP(name, shorthand, value, usage) +} diff --git a/vendor/_nuts/github.com/ogier/pflag/uint16.go b/vendor/_nuts/github.com/ogier/pflag/uint16.go new file mode 100644 index 00000000..182dc409 --- /dev/null +++ b/vendor/_nuts/github.com/ogier/pflag/uint16.go @@ -0,0 +1,71 @@ +package pflag + +import ( + "fmt" + "strconv" +) + +// -- uint16 value +type uint16Value uint16 + +func newUint16Value(val uint16, p *uint16) *uint16Value { + *p = val + return (*uint16Value)(p) +} +func (i *uint16Value) String() string { return fmt.Sprintf("%d", *i) } +func (i *uint16Value) Set(s string) error { + v, err := strconv.ParseUint(s, 0, 16) + *i = uint16Value(v) + return err +} +func (i *uint16Value) Get() interface{} { + return uint16(*i) +} + +// Uint16Var defines a uint flag with specified name, default value, and usage string. +// The argument p points to a uint variable in which to store the value of the flag. +func (f *FlagSet) Uint16Var(p *uint16, name string, value uint16, usage string) { + f.VarP(newUint16Value(value, p), name, "", usage) +} + +// Like Uint16Var, but accepts a shorthand letter that can be used after a single dash. +func (f *FlagSet) Uint16VarP(p *uint16, name, shorthand string, value uint16, usage string) { + f.VarP(newUint16Value(value, p), name, shorthand, usage) +} + +// Uint16Var defines a uint flag with specified name, default value, and usage string. +// The argument p points to a uint variable in which to store the value of the flag. +func Uint16Var(p *uint16, name string, value uint16, usage string) { + CommandLine.VarP(newUint16Value(value, p), name, "", usage) +} + +// Like Uint16Var, but accepts a shorthand letter that can be used after a single dash. +func Uint16VarP(p *uint16, name, shorthand string, value uint16, usage string) { + CommandLine.VarP(newUint16Value(value, p), name, shorthand, usage) +} + +// Uint16 defines a uint flag with specified name, default value, and usage string. +// The return value is the address of a uint variable that stores the value of the flag. +func (f *FlagSet) Uint16(name string, value uint16, usage string) *uint16 { + p := new(uint16) + f.Uint16VarP(p, name, "", value, usage) + return p +} + +// Like Uint16, but accepts a shorthand letter that can be used after a single dash. +func (f *FlagSet) Uint16P(name, shorthand string, value uint16, usage string) *uint16 { + p := new(uint16) + f.Uint16VarP(p, name, shorthand, value, usage) + return p +} + +// Uint16 defines a uint flag with specified name, default value, and usage string. +// The return value is the address of a uint variable that stores the value of the flag. +func Uint16(name string, value uint16, usage string) *uint16 { + return CommandLine.Uint16P(name, "", value, usage) +} + +// Like Uint16, but accepts a shorthand letter that can be used after a single dash. +func Uint16P(name, shorthand string, value uint16, usage string) *uint16 { + return CommandLine.Uint16P(name, shorthand, value, usage) +} diff --git a/vendor/_nuts/github.com/ogier/pflag/uint32.go b/vendor/_nuts/github.com/ogier/pflag/uint32.go new file mode 100644 index 00000000..165c8b25 --- /dev/null +++ b/vendor/_nuts/github.com/ogier/pflag/uint32.go @@ -0,0 +1,71 @@ +package pflag + +import ( + "fmt" + "strconv" +) + +// -- uint16 value +type uint32Value uint32 + +func newUint32Value(val uint32, p *uint32) *uint32Value { + *p = val + return (*uint32Value)(p) +} +func (i *uint32Value) String() string { return fmt.Sprintf("%d", *i) } +func (i *uint32Value) Set(s string) error { + v, err := strconv.ParseUint(s, 0, 32) + *i = uint32Value(v) + return err +} +func (i *uint32Value) Get() interface{} { + return uint32(*i) +} + +// Uint32Var defines a uint32 flag with specified name, default value, and usage string. +// The argument p points to a uint32 variable in which to store the value of the flag. +func (f *FlagSet) Uint32Var(p *uint32, name string, value uint32, usage string) { + f.VarP(newUint32Value(value, p), name, "", usage) +} + +// Like Uint32Var, but accepts a shorthand letter that can be used after a single dash. +func (f *FlagSet) Uint32VarP(p *uint32, name, shorthand string, value uint32, usage string) { + f.VarP(newUint32Value(value, p), name, shorthand, usage) +} + +// Uint32Var defines a uint32 flag with specified name, default value, and usage string. +// The argument p points to a uint32 variable in which to store the value of the flag. +func Uint32Var(p *uint32, name string, value uint32, usage string) { + CommandLine.VarP(newUint32Value(value, p), name, "", usage) +} + +// Like Uint32Var, but accepts a shorthand letter that can be used after a single dash. +func Uint32VarP(p *uint32, name, shorthand string, value uint32, usage string) { + CommandLine.VarP(newUint32Value(value, p), name, shorthand, usage) +} + +// Uint32 defines a uint32 flag with specified name, default value, and usage string. +// The return value is the address of a uint32 variable that stores the value of the flag. +func (f *FlagSet) Uint32(name string, value uint32, usage string) *uint32 { + p := new(uint32) + f.Uint32VarP(p, name, "", value, usage) + return p +} + +// Like Uint32, but accepts a shorthand letter that can be used after a single dash. +func (f *FlagSet) Uint32P(name, shorthand string, value uint32, usage string) *uint32 { + p := new(uint32) + f.Uint32VarP(p, name, shorthand, value, usage) + return p +} + +// Uint32 defines a uint32 flag with specified name, default value, and usage string. +// The return value is the address of a uint32 variable that stores the value of the flag. +func Uint32(name string, value uint32, usage string) *uint32 { + return CommandLine.Uint32P(name, "", value, usage) +} + +// Like Uint32, but accepts a shorthand letter that can be used after a single dash. +func Uint32P(name, shorthand string, value uint32, usage string) *uint32 { + return CommandLine.Uint32P(name, shorthand, value, usage) +} diff --git a/vendor/_nuts/github.com/ogier/pflag/uint64.go b/vendor/_nuts/github.com/ogier/pflag/uint64.go new file mode 100644 index 00000000..f41c5a29 --- /dev/null +++ b/vendor/_nuts/github.com/ogier/pflag/uint64.go @@ -0,0 +1,70 @@ +package pflag + +import ( + "fmt" + "strconv" +) + +// -- uint64 Value +type uint64Value uint64 + +func newUint64Value(val uint64, p *uint64) *uint64Value { + *p = val + return (*uint64Value)(p) +} + +func (i *uint64Value) Set(s string) error { + v, err := strconv.ParseUint(s, 0, 64) + *i = uint64Value(v) + return err +} + +func (i *uint64Value) String() string { return fmt.Sprintf("%v", *i) } + +// Uint64Var defines a uint64 flag with specified name, default value, and usage string. +// The argument p points to a uint64 variable in which to store the value of the flag. +func (f *FlagSet) Uint64Var(p *uint64, name string, value uint64, usage string) { + f.VarP(newUint64Value(value, p), name, "", usage) +} + +// Like Uint64Var, but accepts a shorthand letter that can be used after a single dash. +func (f *FlagSet) Uint64VarP(p *uint64, name, shorthand string, value uint64, usage string) { + f.VarP(newUint64Value(value, p), name, shorthand, usage) +} + +// Uint64Var defines a uint64 flag with specified name, default value, and usage string. +// The argument p points to a uint64 variable in which to store the value of the flag. +func Uint64Var(p *uint64, name string, value uint64, usage string) { + CommandLine.VarP(newUint64Value(value, p), name, "", usage) +} + +// Like Uint64Var, but accepts a shorthand letter that can be used after a single dash. +func Uint64VarP(p *uint64, name, shorthand string, value uint64, usage string) { + CommandLine.VarP(newUint64Value(value, p), name, shorthand, usage) +} + +// Uint64 defines a uint64 flag with specified name, default value, and usage string. +// The return value is the address of a uint64 variable that stores the value of the flag. +func (f *FlagSet) Uint64(name string, value uint64, usage string) *uint64 { + p := new(uint64) + f.Uint64VarP(p, name, "", value, usage) + return p +} + +// Like Uint64, but accepts a shorthand letter that can be used after a single dash. +func (f *FlagSet) Uint64P(name, shorthand string, value uint64, usage string) *uint64 { + p := new(uint64) + f.Uint64VarP(p, name, shorthand, value, usage) + return p +} + +// Uint64 defines a uint64 flag with specified name, default value, and usage string. +// The return value is the address of a uint64 variable that stores the value of the flag. +func Uint64(name string, value uint64, usage string) *uint64 { + return CommandLine.Uint64P(name, "", value, usage) +} + +// Like Uint64, but accepts a shorthand letter that can be used after a single dash. +func Uint64P(name, shorthand string, value uint64, usage string) *uint64 { + return CommandLine.Uint64P(name, shorthand, value, usage) +} diff --git a/vendor/_nuts/github.com/ogier/pflag/uint8.go b/vendor/_nuts/github.com/ogier/pflag/uint8.go new file mode 100644 index 00000000..174f99ca --- /dev/null +++ b/vendor/_nuts/github.com/ogier/pflag/uint8.go @@ -0,0 +1,70 @@ +package pflag + +import ( + "fmt" + "strconv" +) + +// -- uint8 Value +type uint8Value uint8 + +func newUint8Value(val uint8, p *uint8) *uint8Value { + *p = val + return (*uint8Value)(p) +} + +func (i *uint8Value) Set(s string) error { + v, err := strconv.ParseUint(s, 0, 8) + *i = uint8Value(v) + return err +} + +func (i *uint8Value) String() string { return fmt.Sprintf("%v", *i) } + +// Uint8Var defines a uint8 flag with specified name, default value, and usage string. +// The argument p points to a uint8 variable in which to store the value of the flag. +func (f *FlagSet) Uint8Var(p *uint8, name string, value uint8, usage string) { + f.VarP(newUint8Value(value, p), name, "", usage) +} + +// Like Uint8Var, but accepts a shorthand letter that can be used after a single dash. +func (f *FlagSet) Uint8VarP(p *uint8, name, shorthand string, value uint8, usage string) { + f.VarP(newUint8Value(value, p), name, shorthand, usage) +} + +// Uint8Var defines a uint8 flag with specified name, default value, and usage string. +// The argument p points to a uint8 variable in which to store the value of the flag. +func Uint8Var(p *uint8, name string, value uint8, usage string) { + CommandLine.VarP(newUint8Value(value, p), name, "", usage) +} + +// Like Uint8Var, but accepts a shorthand letter that can be used after a single dash. +func Uint8VarP(p *uint8, name, shorthand string, value uint8, usage string) { + CommandLine.VarP(newUint8Value(value, p), name, shorthand, usage) +} + +// Uint8 defines a uint8 flag with specified name, default value, and usage string. +// The return value is the address of a uint8 variable that stores the value of the flag. +func (f *FlagSet) Uint8(name string, value uint8, usage string) *uint8 { + p := new(uint8) + f.Uint8VarP(p, name, "", value, usage) + return p +} + +// Like Uint8, but accepts a shorthand letter that can be used after a single dash. +func (f *FlagSet) Uint8P(name, shorthand string, value uint8, usage string) *uint8 { + p := new(uint8) + f.Uint8VarP(p, name, shorthand, value, usage) + return p +} + +// Uint8 defines a uint8 flag with specified name, default value, and usage string. +// The return value is the address of a uint8 variable that stores the value of the flag. +func Uint8(name string, value uint8, usage string) *uint8 { + return CommandLine.Uint8P(name, "", value, usage) +} + +// Like Uint8, but accepts a shorthand letter that can be used after a single dash. +func Uint8P(name, shorthand string, value uint8, usage string) *uint8 { + return CommandLine.Uint8P(name, shorthand, value, usage) +} diff --git a/.vendor/src/github.com/olekukonko/ts/.travis.yml b/vendor/_nuts/github.com/olekukonko/ts/.travis.yml similarity index 100% rename from .vendor/src/github.com/olekukonko/ts/.travis.yml rename to vendor/_nuts/github.com/olekukonko/ts/.travis.yml diff --git a/.vendor/src/github.com/olekukonko/ts/LICENCE b/vendor/_nuts/github.com/olekukonko/ts/LICENCE similarity index 100% rename from .vendor/src/github.com/olekukonko/ts/LICENCE rename to vendor/_nuts/github.com/olekukonko/ts/LICENCE diff --git a/.vendor/src/github.com/olekukonko/ts/README.md b/vendor/_nuts/github.com/olekukonko/ts/README.md similarity index 100% rename from .vendor/src/github.com/olekukonko/ts/README.md rename to vendor/_nuts/github.com/olekukonko/ts/README.md diff --git a/.vendor/src/github.com/olekukonko/ts/doc.go b/vendor/_nuts/github.com/olekukonko/ts/doc.go similarity index 100% rename from .vendor/src/github.com/olekukonko/ts/doc.go rename to vendor/_nuts/github.com/olekukonko/ts/doc.go diff --git a/.vendor/src/github.com/olekukonko/ts/ts.go b/vendor/_nuts/github.com/olekukonko/ts/ts.go similarity index 100% rename from .vendor/src/github.com/olekukonko/ts/ts.go rename to vendor/_nuts/github.com/olekukonko/ts/ts.go diff --git a/.vendor/src/github.com/olekukonko/ts/ts_darwin.go b/vendor/_nuts/github.com/olekukonko/ts/ts_darwin.go similarity index 100% rename from .vendor/src/github.com/olekukonko/ts/ts_darwin.go rename to vendor/_nuts/github.com/olekukonko/ts/ts_darwin.go diff --git a/.vendor/src/github.com/olekukonko/ts/ts_linux.go b/vendor/_nuts/github.com/olekukonko/ts/ts_linux.go similarity index 100% rename from .vendor/src/github.com/olekukonko/ts/ts_linux.go rename to vendor/_nuts/github.com/olekukonko/ts/ts_linux.go diff --git a/.vendor/src/github.com/olekukonko/ts/ts_other.go b/vendor/_nuts/github.com/olekukonko/ts/ts_other.go similarity index 100% rename from .vendor/src/github.com/olekukonko/ts/ts_other.go rename to vendor/_nuts/github.com/olekukonko/ts/ts_other.go diff --git a/.vendor/src/github.com/olekukonko/ts/ts_test.go b/vendor/_nuts/github.com/olekukonko/ts/ts_test.go similarity index 100% rename from .vendor/src/github.com/olekukonko/ts/ts_test.go rename to vendor/_nuts/github.com/olekukonko/ts/ts_test.go diff --git a/.vendor/src/github.com/olekukonko/ts/ts_unix.go b/vendor/_nuts/github.com/olekukonko/ts/ts_unix.go similarity index 100% rename from .vendor/src/github.com/olekukonko/ts/ts_unix.go rename to vendor/_nuts/github.com/olekukonko/ts/ts_unix.go diff --git a/.vendor/src/github.com/olekukonko/ts/ts_windows.go b/vendor/_nuts/github.com/olekukonko/ts/ts_windows.go similarity index 100% rename from .vendor/src/github.com/olekukonko/ts/ts_windows.go rename to vendor/_nuts/github.com/olekukonko/ts/ts_windows.go diff --git a/.vendor/src/github.com/olekukonko/ts/ts_x.go b/vendor/_nuts/github.com/olekukonko/ts/ts_x.go similarity index 100% rename from .vendor/src/github.com/olekukonko/ts/ts_x.go rename to vendor/_nuts/github.com/olekukonko/ts/ts_x.go diff --git a/.vendor/src/github.com/rubyist/tracerx/LICENSE b/vendor/_nuts/github.com/rubyist/tracerx/LICENSE similarity index 100% rename from .vendor/src/github.com/rubyist/tracerx/LICENSE rename to vendor/_nuts/github.com/rubyist/tracerx/LICENSE diff --git a/.vendor/src/github.com/rubyist/tracerx/README.md b/vendor/_nuts/github.com/rubyist/tracerx/README.md similarity index 100% rename from .vendor/src/github.com/rubyist/tracerx/README.md rename to vendor/_nuts/github.com/rubyist/tracerx/README.md diff --git a/.vendor/src/github.com/rubyist/tracerx/tracerx.go b/vendor/_nuts/github.com/rubyist/tracerx/tracerx.go similarity index 100% rename from .vendor/src/github.com/rubyist/tracerx/tracerx.go rename to vendor/_nuts/github.com/rubyist/tracerx/tracerx.go diff --git a/.vendor/src/github.com/spf13/cobra/.gitignore b/vendor/_nuts/github.com/spf13/cobra/.gitignore similarity index 100% rename from .vendor/src/github.com/spf13/cobra/.gitignore rename to vendor/_nuts/github.com/spf13/cobra/.gitignore diff --git a/.vendor/src/github.com/spf13/cobra/.travis.yml b/vendor/_nuts/github.com/spf13/cobra/.travis.yml similarity index 100% rename from .vendor/src/github.com/spf13/cobra/.travis.yml rename to vendor/_nuts/github.com/spf13/cobra/.travis.yml diff --git a/.vendor/src/github.com/spf13/cobra/LICENSE.txt b/vendor/_nuts/github.com/spf13/cobra/LICENSE.txt similarity index 100% rename from .vendor/src/github.com/spf13/cobra/LICENSE.txt rename to vendor/_nuts/github.com/spf13/cobra/LICENSE.txt diff --git a/.vendor/src/github.com/spf13/cobra/README.md b/vendor/_nuts/github.com/spf13/cobra/README.md similarity index 100% rename from .vendor/src/github.com/spf13/cobra/README.md rename to vendor/_nuts/github.com/spf13/cobra/README.md diff --git a/.vendor/src/github.com/spf13/cobra/cobra.go b/vendor/_nuts/github.com/spf13/cobra/cobra.go similarity index 100% rename from .vendor/src/github.com/spf13/cobra/cobra.go rename to vendor/_nuts/github.com/spf13/cobra/cobra.go diff --git a/.vendor/src/github.com/spf13/cobra/cobra_test.go b/vendor/_nuts/github.com/spf13/cobra/cobra_test.go similarity index 100% rename from .vendor/src/github.com/spf13/cobra/cobra_test.go rename to vendor/_nuts/github.com/spf13/cobra/cobra_test.go diff --git a/.vendor/src/github.com/spf13/cobra/command.go b/vendor/_nuts/github.com/spf13/cobra/command.go similarity index 99% rename from .vendor/src/github.com/spf13/cobra/command.go rename to vendor/_nuts/github.com/spf13/cobra/command.go index dece3258..621e5a2c 100644 --- a/.vendor/src/github.com/spf13/cobra/command.go +++ b/vendor/_nuts/github.com/spf13/cobra/command.go @@ -23,7 +23,7 @@ import ( "os" "strings" - flag "github.com/spf13/pflag" + flag "github.com/github/git-lfs/vendor/_nuts/github.com/spf13/pflag" ) // Command is just that, a command for your application. diff --git a/vendor/_nuts/github.com/spf13/pflag/LICENSE b/vendor/_nuts/github.com/spf13/pflag/LICENSE new file mode 100644 index 00000000..63ed1cfe --- /dev/null +++ b/vendor/_nuts/github.com/spf13/pflag/LICENSE @@ -0,0 +1,28 @@ +Copyright (c) 2012 Alex Ogier. All rights reserved. +Copyright (c) 2012 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/.vendor/src/github.com/spf13/pflag/README.md b/vendor/_nuts/github.com/spf13/pflag/README.md similarity index 100% rename from .vendor/src/github.com/spf13/pflag/README.md rename to vendor/_nuts/github.com/spf13/pflag/README.md diff --git a/.vendor/src/github.com/spf13/pflag/bool.go b/vendor/_nuts/github.com/spf13/pflag/bool.go similarity index 100% rename from .vendor/src/github.com/spf13/pflag/bool.go rename to vendor/_nuts/github.com/spf13/pflag/bool.go diff --git a/.vendor/src/github.com/spf13/pflag/duration.go b/vendor/_nuts/github.com/spf13/pflag/duration.go similarity index 100% rename from .vendor/src/github.com/spf13/pflag/duration.go rename to vendor/_nuts/github.com/spf13/pflag/duration.go diff --git a/vendor/_nuts/github.com/spf13/pflag/example_test.go b/vendor/_nuts/github.com/spf13/pflag/example_test.go new file mode 100644 index 00000000..54f91165 --- /dev/null +++ b/vendor/_nuts/github.com/spf13/pflag/example_test.go @@ -0,0 +1,73 @@ +// Copyright 2012 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// These examples demonstrate more intricate uses of the flag package. +package pflag_test + +import ( + "errors" + "fmt" + "strings" + "time" + + flag "github.com/github/git-lfs/vendor/_nuts/github.com/ogier/pflag" +) + +// Example 1: A single string flag called "species" with default value "gopher". +var species = flag.String("species", "gopher", "the species we are studying") + +// Example 2: A flag with a shorthand letter. +var gopherType = flag.StringP("gopher_type", "g", "pocket", "the variety of gopher") + +// Example 3: A user-defined flag type, a slice of durations. +type interval []time.Duration + +// String is the method to format the flag's value, part of the flag.Value interface. +// The String method's output will be used in diagnostics. +func (i *interval) String() string { + return fmt.Sprint(*i) +} + +// Set is the method to set the flag value, part of the flag.Value interface. +// Set's argument is a string to be parsed to set the flag. +// It's a comma-separated list, so we split it. +func (i *interval) Set(value string) error { + // If we wanted to allow the flag to be set multiple times, + // accumulating values, we would delete this if statement. + // That would permit usages such as + // -deltaT 10s -deltaT 15s + // and other combinations. + if len(*i) > 0 { + return errors.New("interval flag already set") + } + for _, dt := range strings.Split(value, ",") { + duration, err := time.ParseDuration(dt) + if err != nil { + return err + } + *i = append(*i, duration) + } + return nil +} + +// Define a flag to accumulate durations. Because it has a special type, +// we need to use the Var function and therefore create the flag during +// init. + +var intervalFlag interval + +func init() { + // Tie the command-line flag to the intervalFlag variable and + // set a usage message. + flag.Var(&intervalFlag, "deltaT", "comma-separated list of intervals to use between events") +} + +func Example() { + // All the interesting pieces are with the variables declared above, but + // to enable the flag package to see the flags defined there, one must + // execute, typically at the start of main (not init!): + // flag.Parse() + // We don't run it here because this is not a main function and + // the testing suite has already parsed the flags. +} diff --git a/vendor/_nuts/github.com/spf13/pflag/export_test.go b/vendor/_nuts/github.com/spf13/pflag/export_test.go new file mode 100644 index 00000000..9318fee0 --- /dev/null +++ b/vendor/_nuts/github.com/spf13/pflag/export_test.go @@ -0,0 +1,29 @@ +// Copyright 2010 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package pflag + +import ( + "io/ioutil" + "os" +) + +// Additional routines compiled into the package only during testing. + +// ResetForTesting clears all flag state and sets the usage function as directed. +// After calling ResetForTesting, parse errors in flag handling will not +// exit the program. +func ResetForTesting(usage func()) { + CommandLine = &FlagSet{ + name: os.Args[0], + errorHandling: ContinueOnError, + output: ioutil.Discard, + } + Usage = usage +} + +// GetCommandLine returns the default FlagSet. +func GetCommandLine() *FlagSet { + return CommandLine +} diff --git a/.vendor/src/github.com/spf13/pflag/flag.go b/vendor/_nuts/github.com/spf13/pflag/flag.go similarity index 100% rename from .vendor/src/github.com/spf13/pflag/flag.go rename to vendor/_nuts/github.com/spf13/pflag/flag.go diff --git a/.vendor/src/github.com/spf13/pflag/flag_test.go b/vendor/_nuts/github.com/spf13/pflag/flag_test.go similarity index 99% rename from .vendor/src/github.com/spf13/pflag/flag_test.go rename to vendor/_nuts/github.com/spf13/pflag/flag_test.go index 4d95b159..209c4f46 100644 --- a/.vendor/src/github.com/spf13/pflag/flag_test.go +++ b/vendor/_nuts/github.com/spf13/pflag/flag_test.go @@ -14,7 +14,7 @@ import ( "testing" "time" - . "github.com/spf13/pflag" + . "github.com/github/git-lfs/vendor/_nuts/github.com/spf13/pflag" ) var ( diff --git a/.vendor/src/github.com/spf13/pflag/float32.go b/vendor/_nuts/github.com/spf13/pflag/float32.go similarity index 100% rename from .vendor/src/github.com/spf13/pflag/float32.go rename to vendor/_nuts/github.com/spf13/pflag/float32.go diff --git a/.vendor/src/github.com/spf13/pflag/float64.go b/vendor/_nuts/github.com/spf13/pflag/float64.go similarity index 100% rename from .vendor/src/github.com/spf13/pflag/float64.go rename to vendor/_nuts/github.com/spf13/pflag/float64.go diff --git a/.vendor/src/github.com/spf13/pflag/int.go b/vendor/_nuts/github.com/spf13/pflag/int.go similarity index 100% rename from .vendor/src/github.com/spf13/pflag/int.go rename to vendor/_nuts/github.com/spf13/pflag/int.go diff --git a/.vendor/src/github.com/spf13/pflag/int32.go b/vendor/_nuts/github.com/spf13/pflag/int32.go similarity index 100% rename from .vendor/src/github.com/spf13/pflag/int32.go rename to vendor/_nuts/github.com/spf13/pflag/int32.go diff --git a/.vendor/src/github.com/spf13/pflag/int64.go b/vendor/_nuts/github.com/spf13/pflag/int64.go similarity index 100% rename from .vendor/src/github.com/spf13/pflag/int64.go rename to vendor/_nuts/github.com/spf13/pflag/int64.go diff --git a/.vendor/src/github.com/spf13/pflag/int8.go b/vendor/_nuts/github.com/spf13/pflag/int8.go similarity index 100% rename from .vendor/src/github.com/spf13/pflag/int8.go rename to vendor/_nuts/github.com/spf13/pflag/int8.go diff --git a/.vendor/src/github.com/spf13/pflag/ip.go b/vendor/_nuts/github.com/spf13/pflag/ip.go similarity index 100% rename from .vendor/src/github.com/spf13/pflag/ip.go rename to vendor/_nuts/github.com/spf13/pflag/ip.go diff --git a/.vendor/src/github.com/spf13/pflag/ipmask.go b/vendor/_nuts/github.com/spf13/pflag/ipmask.go similarity index 100% rename from .vendor/src/github.com/spf13/pflag/ipmask.go rename to vendor/_nuts/github.com/spf13/pflag/ipmask.go diff --git a/.vendor/src/github.com/spf13/pflag/string.go b/vendor/_nuts/github.com/spf13/pflag/string.go similarity index 100% rename from .vendor/src/github.com/spf13/pflag/string.go rename to vendor/_nuts/github.com/spf13/pflag/string.go diff --git a/.vendor/src/github.com/spf13/pflag/uint.go b/vendor/_nuts/github.com/spf13/pflag/uint.go similarity index 100% rename from .vendor/src/github.com/spf13/pflag/uint.go rename to vendor/_nuts/github.com/spf13/pflag/uint.go diff --git a/.vendor/src/github.com/spf13/pflag/uint16.go b/vendor/_nuts/github.com/spf13/pflag/uint16.go similarity index 100% rename from .vendor/src/github.com/spf13/pflag/uint16.go rename to vendor/_nuts/github.com/spf13/pflag/uint16.go diff --git a/.vendor/src/github.com/spf13/pflag/uint32.go b/vendor/_nuts/github.com/spf13/pflag/uint32.go similarity index 100% rename from .vendor/src/github.com/spf13/pflag/uint32.go rename to vendor/_nuts/github.com/spf13/pflag/uint32.go diff --git a/.vendor/src/github.com/spf13/pflag/uint64.go b/vendor/_nuts/github.com/spf13/pflag/uint64.go similarity index 100% rename from .vendor/src/github.com/spf13/pflag/uint64.go rename to vendor/_nuts/github.com/spf13/pflag/uint64.go diff --git a/.vendor/src/github.com/spf13/pflag/uint8.go b/vendor/_nuts/github.com/spf13/pflag/uint8.go similarity index 100% rename from .vendor/src/github.com/spf13/pflag/uint8.go rename to vendor/_nuts/github.com/spf13/pflag/uint8.go diff --git a/.vendor/src/github.com/bmizerany/assert/.gitignore b/vendor/_nuts/github.com/technoweenie/assert/.gitignore similarity index 100% rename from .vendor/src/github.com/bmizerany/assert/.gitignore rename to vendor/_nuts/github.com/technoweenie/assert/.gitignore diff --git a/.vendor/src/github.com/bmizerany/assert/README.md b/vendor/_nuts/github.com/technoweenie/assert/README.md similarity index 100% rename from .vendor/src/github.com/bmizerany/assert/README.md rename to vendor/_nuts/github.com/technoweenie/assert/README.md diff --git a/.vendor/src/github.com/bmizerany/assert/assert.go b/vendor/_nuts/github.com/technoweenie/assert/assert.go similarity index 96% rename from .vendor/src/github.com/bmizerany/assert/assert.go rename to vendor/_nuts/github.com/technoweenie/assert/assert.go index 7409f985..038164c7 100644 --- a/.vendor/src/github.com/bmizerany/assert/assert.go +++ b/vendor/_nuts/github.com/technoweenie/assert/assert.go @@ -1,8 +1,9 @@ package assert + // Testing helpers for doozer. import ( - "github.com/kr/pretty" + "github.com/github/git-lfs/vendor/_nuts/github.com/kr/pretty" "reflect" "testing" "runtime" diff --git a/.vendor/src/github.com/bmizerany/assert/assert_test.go b/vendor/_nuts/github.com/technoweenie/assert/assert_test.go similarity index 100% rename from .vendor/src/github.com/bmizerany/assert/assert_test.go rename to vendor/_nuts/github.com/technoweenie/assert/assert_test.go diff --git a/.vendor/src/github.com/bmizerany/assert/example/point.go b/vendor/_nuts/github.com/technoweenie/assert/example/point.go similarity index 100% rename from .vendor/src/github.com/bmizerany/assert/example/point.go rename to vendor/_nuts/github.com/technoweenie/assert/example/point.go diff --git a/.vendor/src/github.com/bmizerany/assert/example/point_test.go b/vendor/_nuts/github.com/technoweenie/assert/example/point_test.go similarity index 65% rename from .vendor/src/github.com/bmizerany/assert/example/point_test.go rename to vendor/_nuts/github.com/technoweenie/assert/example/point_test.go index 34e791a4..dcf74603 100644 --- a/.vendor/src/github.com/bmizerany/assert/example/point_test.go +++ b/vendor/_nuts/github.com/technoweenie/assert/example/point_test.go @@ -2,7 +2,7 @@ package point import ( "testing" - "assert" + "github.com/github/git-lfs/vendor/_nuts/github.com/technoweenie/assert" ) func TestAsserts(t *testing.T) { diff --git a/.vendor/src/github.com/technoweenie/go-contentaddressable/LICENSE b/vendor/_nuts/github.com/technoweenie/go-contentaddressable/LICENSE similarity index 100% rename from .vendor/src/github.com/technoweenie/go-contentaddressable/LICENSE rename to vendor/_nuts/github.com/technoweenie/go-contentaddressable/LICENSE diff --git a/.vendor/src/github.com/technoweenie/go-contentaddressable/README.md b/vendor/_nuts/github.com/technoweenie/go-contentaddressable/README.md similarity index 100% rename from .vendor/src/github.com/technoweenie/go-contentaddressable/README.md rename to vendor/_nuts/github.com/technoweenie/go-contentaddressable/README.md diff --git a/.vendor/src/github.com/technoweenie/go-contentaddressable/contentaddressable.go b/vendor/_nuts/github.com/technoweenie/go-contentaddressable/contentaddressable.go similarity index 100% rename from .vendor/src/github.com/technoweenie/go-contentaddressable/contentaddressable.go rename to vendor/_nuts/github.com/technoweenie/go-contentaddressable/contentaddressable.go diff --git a/.vendor/src/github.com/technoweenie/go-contentaddressable/file.go b/vendor/_nuts/github.com/technoweenie/go-contentaddressable/file.go similarity index 100% rename from .vendor/src/github.com/technoweenie/go-contentaddressable/file.go rename to vendor/_nuts/github.com/technoweenie/go-contentaddressable/file.go diff --git a/.vendor/src/github.com/technoweenie/go-contentaddressable/file_test.go b/vendor/_nuts/github.com/technoweenie/go-contentaddressable/file_test.go similarity index 100% rename from .vendor/src/github.com/technoweenie/go-contentaddressable/file_test.go rename to vendor/_nuts/github.com/technoweenie/go-contentaddressable/file_test.go