mirror of
https://github.com/fatedier/frp.git
synced 2026-01-11 22:23:12 +00:00
using glide
This commit is contained in:
1536
vendor/github.com/docopt/docopt-go/docopt_test.go
generated
vendored
Normal file
1536
vendor/github.com/docopt/docopt-go/docopt_test.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
37
vendor/github.com/docopt/docopt-go/example_test.go
generated
vendored
Normal file
37
vendor/github.com/docopt/docopt-go/example_test.go
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
package docopt
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
)
|
||||
|
||||
func ExampleParse() {
|
||||
usage := `Usage:
|
||||
config_example tcp [<host>] [--force] [--timeout=<seconds>]
|
||||
config_example serial <port> [--baud=<rate>] [--timeout=<seconds>]
|
||||
config_example -h | --help | --version`
|
||||
// parse the command line `comfig_example tcp 127.0.0.1 --force`
|
||||
argv := []string{"tcp", "127.0.0.1", "--force"}
|
||||
arguments, _ := Parse(usage, argv, true, "0.1.1rc", false)
|
||||
// sort the keys of the arguments map
|
||||
var keys []string
|
||||
for k := range arguments {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
// print the argument keys and values
|
||||
for _, k := range keys {
|
||||
fmt.Printf("%9s %v\n", k, arguments[k])
|
||||
}
|
||||
// output:
|
||||
// --baud <nil>
|
||||
// --force true
|
||||
// --help false
|
||||
// --timeout <nil>
|
||||
// --version false
|
||||
// -h false
|
||||
// <host> 127.0.0.1
|
||||
// <port> <nil>
|
||||
// serial false
|
||||
// tcp true
|
||||
}
|
||||
29
vendor/github.com/docopt/docopt-go/examples/arguments/arguments_example.go
generated
vendored
Normal file
29
vendor/github.com/docopt/docopt-go/examples/arguments/arguments_example.go
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/docopt/docopt-go"
|
||||
)
|
||||
|
||||
func main() {
|
||||
usage := `Usage: arguments_example [-vqrh] [FILE] ...
|
||||
arguments_example (--left | --right) CORRECTION FILE
|
||||
|
||||
Process FILE and optionally apply correction to either left-hand side or
|
||||
right-hand side.
|
||||
|
||||
Arguments:
|
||||
FILE optional input file
|
||||
CORRECTION correction angle, needs FILE, --left or --right to be present
|
||||
|
||||
Options:
|
||||
-h --help
|
||||
-v verbose mode
|
||||
-q quiet mode
|
||||
-r make report
|
||||
--left use left-hand side
|
||||
--right use right-hand side`
|
||||
|
||||
arguments, _ := docopt.Parse(usage, nil, true, "", false)
|
||||
fmt.Println(arguments)
|
||||
}
|
||||
26
vendor/github.com/docopt/docopt-go/examples/calculator/calculator_example.go
generated
vendored
Normal file
26
vendor/github.com/docopt/docopt-go/examples/calculator/calculator_example.go
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/docopt/docopt-go"
|
||||
)
|
||||
|
||||
func main() {
|
||||
usage := `Not a serious example.
|
||||
|
||||
Usage:
|
||||
calculator_example <value> ( ( + | - | * | / ) <value> )...
|
||||
calculator_example <function> <value> [( , <value> )]...
|
||||
calculator_example (-h | --help)
|
||||
|
||||
Examples:
|
||||
calculator_example 1 + 2 + 3 + 4 + 5
|
||||
calculator_example 1 + 2 '*' 3 / 4 - 5 # note quotes around '*'
|
||||
calculator_example sum 10 , 20 , 30 , 40
|
||||
|
||||
Options:
|
||||
-h, --help
|
||||
`
|
||||
arguments, _ := docopt.Parse(usage, nil, true, "", false)
|
||||
fmt.Println(arguments)
|
||||
}
|
||||
76
vendor/github.com/docopt/docopt-go/examples/config_file/config_file_example.go
generated
vendored
Normal file
76
vendor/github.com/docopt/docopt-go/examples/config_file/config_file_example.go
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/docopt/docopt-go"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func loadJSONConfig() map[string]interface{} {
|
||||
var result map[string]interface{}
|
||||
jsonData := []byte(`{"--force": true, "--timeout": "10", "--baud": "9600"}`)
|
||||
json.Unmarshal(jsonData, &result)
|
||||
return result
|
||||
}
|
||||
|
||||
func loadIniConfig() map[string]interface{} {
|
||||
iniData := `
|
||||
[default-arguments]
|
||||
--force
|
||||
--baud=19200
|
||||
<host>=localhost`
|
||||
// trivial ini parser
|
||||
// default value for an item is bool: true (for --force)
|
||||
// otherwise the value is a string
|
||||
iniParsed := make(map[string]map[string]interface{})
|
||||
var section string
|
||||
for _, line := range strings.Split(iniData, "\n") {
|
||||
if strings.HasPrefix(line, "[") {
|
||||
section = line
|
||||
iniParsed[section] = make(map[string]interface{})
|
||||
} else if section != "" {
|
||||
kv := strings.SplitN(line, "=", 2)
|
||||
if len(kv) == 1 {
|
||||
iniParsed[section][kv[0]] = true
|
||||
} else if len(kv) == 2 {
|
||||
iniParsed[section][kv[0]] = kv[1]
|
||||
}
|
||||
}
|
||||
}
|
||||
return iniParsed["[default-arguments]"]
|
||||
}
|
||||
|
||||
// merge combines two maps.
|
||||
// truthiness takes priority over falsiness
|
||||
// mapA takes priority over mapB
|
||||
func merge(mapA, mapB map[string]interface{}) map[string]interface{} {
|
||||
result := make(map[string]interface{})
|
||||
for k, v := range mapA {
|
||||
result[k] = v
|
||||
}
|
||||
for k, v := range mapB {
|
||||
if _, ok := result[k]; !ok || result[k] == nil || result[k] == false {
|
||||
result[k] = v
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func main() {
|
||||
usage := `Usage:
|
||||
config_file_example tcp [<host>] [--force] [--timeout=<seconds>]
|
||||
config_file_example serial <port> [--baud=<rate>] [--timeout=<seconds>]
|
||||
config_file_example -h | --help | --version`
|
||||
|
||||
jsonConfig := loadJSONConfig()
|
||||
iniConfig := loadIniConfig()
|
||||
arguments, _ := docopt.Parse(usage, nil, true, "0.1.1rc", false)
|
||||
|
||||
// Arguments take priority over INI, INI takes priority over JSON
|
||||
result := merge(arguments, merge(iniConfig, jsonConfig))
|
||||
|
||||
fmt.Println("JSON config: ", jsonConfig)
|
||||
fmt.Println("INI config: ", iniConfig)
|
||||
fmt.Println("Result: ", result)
|
||||
}
|
||||
22
vendor/github.com/docopt/docopt-go/examples/counted/counted_example.go
generated
vendored
Normal file
22
vendor/github.com/docopt/docopt-go/examples/counted/counted_example.go
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/docopt/docopt-go"
|
||||
)
|
||||
|
||||
func main() {
|
||||
usage := `Usage: counted_example --help
|
||||
counted_example -v...
|
||||
counted_example go [go]
|
||||
counted_example (--path=<path>)...
|
||||
counted_example <file> <file>
|
||||
|
||||
Try: counted_example -vvvvvvvvvv
|
||||
counted_example go go
|
||||
counted_example --path ./here --path ./there
|
||||
counted_example this.txt that.txt`
|
||||
|
||||
arguments, _ := docopt.Parse(usage, nil, true, "", false)
|
||||
fmt.Println(arguments)
|
||||
}
|
||||
38
vendor/github.com/docopt/docopt-go/examples/git/branch/git_branch.go
generated
vendored
Normal file
38
vendor/github.com/docopt/docopt-go/examples/git/branch/git_branch.go
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
package git
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/docopt/docopt-go"
|
||||
)
|
||||
|
||||
func main() {
|
||||
usage := `usage: git branch [options] [-r | -a] [--merged=<commit> | --no-merged=<commit>]
|
||||
git branch [options] [-l] [-f] <branchname> [<start-point>]
|
||||
git branch [options] [-r] (-d | -D) <branchname>
|
||||
git branch [options] (-m | -M) [<oldbranch>] <newbranch>
|
||||
|
||||
Generic options:
|
||||
-h, --help
|
||||
-v, --verbose show hash and subject, give twice for upstream branch
|
||||
-t, --track set up tracking mode (see git-pull(1))
|
||||
--set-upstream change upstream info
|
||||
--color=<when> use colored output
|
||||
-r act on remote-tracking branches
|
||||
--contains=<commit> print only branches that contain the commit
|
||||
--abbrev=<n> use <n> digits to display SHA-1s
|
||||
|
||||
Specific git-branch actions:
|
||||
-a list both remote-tracking and local branches
|
||||
-d delete fully merged branch
|
||||
-D delete branch (even if not merged)
|
||||
-m move/rename a branch and its reflog
|
||||
-M move/rename a branch, even if target exists
|
||||
-l create the branch's reflog
|
||||
-f, --force force creation (when already exists)
|
||||
--no-merged=<commit> print only not merged branches
|
||||
--merged=<commit> print only merged branches
|
||||
`
|
||||
|
||||
args, _ := docopt.Parse(usage, nil, true, "", false)
|
||||
fmt.Println(args)
|
||||
}
|
||||
30
vendor/github.com/docopt/docopt-go/examples/git/checkout/git_checkout.go
generated
vendored
Normal file
30
vendor/github.com/docopt/docopt-go/examples/git/checkout/git_checkout.go
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
package git
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/docopt/docopt-go"
|
||||
)
|
||||
|
||||
func main() {
|
||||
usage := `usage: git checkout [options] <branch>
|
||||
git checkout [options] <branch> -- <file>...
|
||||
|
||||
options:
|
||||
-q, --quiet suppress progress reporting
|
||||
-b <branch> create and checkout a new branch
|
||||
-B <branch> create/reset and checkout a branch
|
||||
-l create reflog for new branch
|
||||
-t, --track set upstream info for new branch
|
||||
--orphan <new branch>
|
||||
new unparented branch
|
||||
-2, --ours checkout our version for unmerged files
|
||||
-3, --theirs checkout their version for unmerged files
|
||||
-f, --force force checkout (throw away local modifications)
|
||||
-m, --merge perform a 3-way merge with the new branch
|
||||
--conflict <style> conflict style (merge or diff3)
|
||||
-p, --patch select hunks interactively
|
||||
`
|
||||
|
||||
args, _ := docopt.Parse(usage, nil, true, "", false)
|
||||
fmt.Println(args)
|
||||
}
|
||||
37
vendor/github.com/docopt/docopt-go/examples/git/clone/git_clone.go
generated
vendored
Normal file
37
vendor/github.com/docopt/docopt-go/examples/git/clone/git_clone.go
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
package git
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/docopt/docopt-go"
|
||||
)
|
||||
|
||||
func main() {
|
||||
usage := `usage: git clone [options] [--] <repo> [<dir>]
|
||||
|
||||
options:
|
||||
-v, --verbose be more verbose
|
||||
-q, --quiet be more quiet
|
||||
--progress force progress reporting
|
||||
-n, --no-checkout don't create a checkout
|
||||
--bare create a bare repository
|
||||
--mirror create a mirror repository (implies bare)
|
||||
-l, --local to clone from a local repository
|
||||
--no-hardlinks don't use local hardlinks, always copy
|
||||
-s, --shared setup as shared repository
|
||||
--recursive initialize submodules in the clone
|
||||
--recurse-submodules initialize submodules in the clone
|
||||
--template <template-directory>
|
||||
directory from which templates will be used
|
||||
--reference <repo> reference repository
|
||||
-o, --origin <branch>
|
||||
use <branch> instead of 'origin' to track upstream
|
||||
-b, --branch <branch>
|
||||
checkout <branch> instead of the remote's HEAD
|
||||
-u, --upload-pack <path>
|
||||
path to git-upload-pack on the remote
|
||||
--depth <depth> create a shallow clone of that depth
|
||||
`
|
||||
|
||||
args, _ := docopt.Parse(usage, nil, true, "", false)
|
||||
fmt.Println(args)
|
||||
}
|
||||
108
vendor/github.com/docopt/docopt-go/examples/git/git.go
generated
vendored
Normal file
108
vendor/github.com/docopt/docopt-go/examples/git/git.go
generated
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/docopt/docopt-go"
|
||||
"os"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
func main() {
|
||||
usage := `usage: git [--version] [--exec-path=<path>] [--html-path]
|
||||
[-p|--paginate|--no-pager] [--no-replace-objects]
|
||||
[--bare] [--git-dir=<path>] [--work-tree=<path>]
|
||||
[-c <name>=<value>] [--help]
|
||||
<command> [<args>...]
|
||||
|
||||
options:
|
||||
-c <name=value>
|
||||
-h, --help
|
||||
-p, --paginate
|
||||
|
||||
The most commonly used git commands are:
|
||||
add Add file contents to the index
|
||||
branch List, create, or delete branches
|
||||
checkout Checkout a branch or paths to the working tree
|
||||
clone Clone a repository into a new directory
|
||||
commit Record changes to the repository
|
||||
push Update remote refs along with associated objects
|
||||
remote Manage set of tracked repositories
|
||||
|
||||
See 'git help <command>' for more information on a specific command.
|
||||
`
|
||||
args, _ := docopt.Parse(usage, nil, true, "git version 1.7.4.4", true)
|
||||
|
||||
fmt.Println("global arguments:")
|
||||
fmt.Println(args)
|
||||
|
||||
fmt.Println("command arguments:")
|
||||
cmd := args["<command>"].(string)
|
||||
cmdArgs := args["<args>"].([]string)
|
||||
|
||||
err := runCommand(cmd, cmdArgs)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func goRun(scriptName string, args []string) (err error) {
|
||||
cmdArgs := make([]string, 2)
|
||||
cmdArgs[0] = "run"
|
||||
cmdArgs[1] = scriptName
|
||||
cmdArgs = append(cmdArgs, args...)
|
||||
osCmd := exec.Command("go", cmdArgs...)
|
||||
var out []byte
|
||||
out, err = osCmd.Output()
|
||||
fmt.Println(string(out))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func runCommand(cmd string, args []string) (err error) {
|
||||
argv := make([]string, 1)
|
||||
argv[0] = cmd
|
||||
argv = append(argv, args...)
|
||||
switch cmd {
|
||||
case "add":
|
||||
// subcommand is a function call
|
||||
return cmdAdd(argv)
|
||||
case "branch":
|
||||
// subcommand is a script
|
||||
return goRun("branch/git_branch.go", argv)
|
||||
case "checkout", "clone", "commit", "push", "remote":
|
||||
// subcommand is a script
|
||||
scriptName := fmt.Sprintf("%s/git_%s.go", cmd, cmd)
|
||||
return goRun(scriptName, argv)
|
||||
case "help", "":
|
||||
return goRun("git.go", []string{"git_add.go", "--help"})
|
||||
}
|
||||
|
||||
return fmt.Errorf("%s is not a git command. See 'git help'", cmd)
|
||||
}
|
||||
|
||||
func cmdAdd(argv []string) (err error) {
|
||||
usage := `usage: git add [options] [--] [<filepattern>...]
|
||||
|
||||
options:
|
||||
-h, --help
|
||||
-n, --dry-run dry run
|
||||
-v, --verbose be verbose
|
||||
-i, --interactive interactive picking
|
||||
-p, --patch select hunks interactively
|
||||
-e, --edit edit current diff and apply
|
||||
-f, --force allow adding otherwise ignored files
|
||||
-u, --update update tracked files
|
||||
-N, --intent-to-add record only the fact that the path will be added later
|
||||
-A, --all add all, noticing removal of tracked files
|
||||
--refresh don't add, only refresh the index
|
||||
--ignore-errors just skip files which cannot be added because of errors
|
||||
--ignore-missing check if - even missing - files are ignored in dry run
|
||||
`
|
||||
|
||||
args, _ := docopt.Parse(usage, nil, true, "", false)
|
||||
fmt.Println(args)
|
||||
return
|
||||
}
|
||||
34
vendor/github.com/docopt/docopt-go/examples/git/push/git_push.go
generated
vendored
Normal file
34
vendor/github.com/docopt/docopt-go/examples/git/push/git_push.go
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
package git
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/docopt/docopt-go"
|
||||
)
|
||||
|
||||
func main() {
|
||||
usage := `usage: git push [options] [<repository> [<refspec>...]]
|
||||
|
||||
options:
|
||||
-h, --help
|
||||
-v, --verbose be more verbose
|
||||
-q, --quiet be more quiet
|
||||
--repo <repository> repository
|
||||
--all push all refs
|
||||
--mirror mirror all refs
|
||||
--delete delete refs
|
||||
--tags push tags (can't be used with --all or --mirror)
|
||||
-n, --dry-run dry run
|
||||
--porcelain machine-readable output
|
||||
-f, --force force updates
|
||||
--thin use thin pack
|
||||
--receive-pack <receive-pack>
|
||||
receive pack program
|
||||
--exec <receive-pack>
|
||||
receive pack program
|
||||
-u, --set-upstream set upstream for git pull/status
|
||||
--progress force progress reporting
|
||||
`
|
||||
|
||||
args, _ := docopt.Parse(usage, nil, true, "", false)
|
||||
fmt.Println(args)
|
||||
}
|
||||
28
vendor/github.com/docopt/docopt-go/examples/git/remote/git_remote.go
generated
vendored
Normal file
28
vendor/github.com/docopt/docopt-go/examples/git/remote/git_remote.go
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
package git
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/docopt/docopt-go"
|
||||
)
|
||||
|
||||
func main() {
|
||||
usage := `usage: git remote [-v | --verbose]
|
||||
git remote add [-t <branch>] [-m <master>] [-f] [--mirror] <name> <url>
|
||||
git remote rename <old> <new>
|
||||
git remote rm <name>
|
||||
git remote set-head <name> (-a | -d | <branch>)
|
||||
git remote [-v | --verbose] show [-n] <name>
|
||||
git remote prune [-n | --dry-run] <name>
|
||||
git remote [-v | --verbose] update [-p | --prune] [(<group> | <remote>)...]
|
||||
git remote set-branches <name> [--add] <branch>...
|
||||
git remote set-url <name> <newurl> [<oldurl>]
|
||||
git remote set-url --add <name> <newurl>
|
||||
git remote set-url --delete <name> <url>
|
||||
|
||||
options:
|
||||
-v, --verbose be verbose; must be placed before a subcommand
|
||||
`
|
||||
|
||||
args, _ := docopt.Parse(usage, nil, true, "", false)
|
||||
fmt.Println(args)
|
||||
}
|
||||
28
vendor/github.com/docopt/docopt-go/examples/naval_fate/naval_fate.go
generated
vendored
Normal file
28
vendor/github.com/docopt/docopt-go/examples/naval_fate/naval_fate.go
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/docopt/docopt-go"
|
||||
)
|
||||
|
||||
func main() {
|
||||
usage := `Naval Fate.
|
||||
|
||||
Usage:
|
||||
naval_fate ship new <name>...
|
||||
naval_fate ship <name> move <x> <y> [--speed=<kn>]
|
||||
naval_fate ship shoot <x> <y>
|
||||
naval_fate mine (set|remove) <x> <y> [--moored|--drifting]
|
||||
naval_fate -h | --help
|
||||
naval_fate --version
|
||||
|
||||
Options:
|
||||
-h --help Show this screen.
|
||||
--version Show version.
|
||||
--speed=<kn> Speed in knots [default: 10].
|
||||
--moored Moored (anchored) mine.
|
||||
--drifting Drifting mine.`
|
||||
|
||||
arguments, _ := docopt.Parse(usage, nil, true, "Naval Fate 2.0", false)
|
||||
fmt.Println(arguments)
|
||||
}
|
||||
19
vendor/github.com/docopt/docopt-go/examples/odd_even/odd_even_example.go
generated
vendored
Normal file
19
vendor/github.com/docopt/docopt-go/examples/odd_even/odd_even_example.go
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/docopt/docopt-go"
|
||||
)
|
||||
|
||||
func main() {
|
||||
usage := `Usage: odd_even_example [-h | --help] (ODD EVEN)...
|
||||
|
||||
Example, try:
|
||||
odd_even_example 1 2 3 4
|
||||
|
||||
Options:
|
||||
-h, --help`
|
||||
|
||||
arguments, _ := docopt.Parse(usage, nil, true, "", false)
|
||||
fmt.Println(arguments)
|
||||
}
|
||||
43
vendor/github.com/docopt/docopt-go/examples/options/options_example.go
generated
vendored
Normal file
43
vendor/github.com/docopt/docopt-go/examples/options/options_example.go
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/docopt/docopt-go"
|
||||
)
|
||||
|
||||
func main() {
|
||||
usage := `Example of program with many options using docopt.
|
||||
|
||||
Usage:
|
||||
options_example [-hvqrf NAME] [--exclude=PATTERNS]
|
||||
[--select=ERRORS | --ignore=ERRORS] [--show-source]
|
||||
[--statistics] [--count] [--benchmark] PATH...
|
||||
options_example (--doctest | --testsuite=DIR)
|
||||
options_example --version
|
||||
|
||||
Arguments:
|
||||
PATH destination path
|
||||
|
||||
Options:
|
||||
-h --help show this help message and exit
|
||||
--version show version and exit
|
||||
-v --verbose print status messages
|
||||
-q --quiet report only file names
|
||||
-r --repeat show all occurrences of the same error
|
||||
--exclude=PATTERNS exclude files or directories which match these comma
|
||||
separated patterns [default: .svn,CVS,.bzr,.hg,.git]
|
||||
-f NAME --file=NAME when parsing directories, only check filenames matching
|
||||
these comma separated patterns [default: *.go]
|
||||
--select=ERRORS select errors and warnings (e.g. E,W6)
|
||||
--ignore=ERRORS skip errors and warnings (e.g. E4,W)
|
||||
--show-source show source code for each error
|
||||
--statistics count errors and warnings
|
||||
--count print total number of errors and warnings to standard
|
||||
error and set exit code to 1 if total is not null
|
||||
--benchmark measure processing speed
|
||||
--testsuite=DIR run regression tests from dir
|
||||
--doctest run doctest on myself`
|
||||
|
||||
arguments, _ := docopt.Parse(usage, nil, true, "1.0.0rc2", false)
|
||||
fmt.Println(arguments)
|
||||
}
|
||||
24
vendor/github.com/docopt/docopt-go/examples/options_shortcut/options_shortcut_example.go
generated
vendored
Normal file
24
vendor/github.com/docopt/docopt-go/examples/options_shortcut/options_shortcut_example.go
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/docopt/docopt-go"
|
||||
)
|
||||
|
||||
func main() {
|
||||
usage := `Example of program which uses [options] shortcut in pattern.
|
||||
|
||||
Usage:
|
||||
options_shortcut_example [options] <port>
|
||||
|
||||
Options:
|
||||
-h --help show this help message and exit
|
||||
--version show version and exit
|
||||
-n, --number N use N as a number
|
||||
-t, --timeout TIMEOUT set timeout TIMEOUT seconds
|
||||
--apply apply changes to database
|
||||
-q operate in quiet mode`
|
||||
|
||||
arguments, _ := docopt.Parse(usage, nil, true, "1.0.0rc2", false)
|
||||
fmt.Println(arguments)
|
||||
}
|
||||
16
vendor/github.com/docopt/docopt-go/examples/quick/quick_example.go
generated
vendored
Normal file
16
vendor/github.com/docopt/docopt-go/examples/quick/quick_example.go
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/docopt/docopt-go"
|
||||
)
|
||||
|
||||
func main() {
|
||||
usage := `Usage:
|
||||
quick_example tcp <host> <port> [--timeout=<seconds>]
|
||||
quick_example serial <port> [--baud=9600] [--timeout=<seconds>]
|
||||
quick_example -h | --help | --version`
|
||||
|
||||
arguments, _ := docopt.Parse(usage, nil, true, "0.1.1rc", false)
|
||||
fmt.Println(arguments)
|
||||
}
|
||||
31
vendor/github.com/docopt/docopt-go/examples/type_assert/type_assert_example.go
generated
vendored
Normal file
31
vendor/github.com/docopt/docopt-go/examples/type_assert/type_assert_example.go
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/docopt/docopt-go"
|
||||
)
|
||||
|
||||
func main() {
|
||||
usage := `usage: foo [-x] [-y]`
|
||||
|
||||
arguments, err := docopt.Parse(usage, nil, true, "", false)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
fmt.Println(arguments)
|
||||
|
||||
var x = arguments["-x"].(bool) // type assertion required
|
||||
if x == true {
|
||||
fmt.Println("x is true")
|
||||
}
|
||||
|
||||
y := arguments["-y"] // no type assertion needed
|
||||
if y == true {
|
||||
fmt.Println("y is true")
|
||||
}
|
||||
y2 := arguments["-y"]
|
||||
if y2 == 10 { // this will never be true, a type assertion would have produced a build error
|
||||
fmt.Println("y is 10")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user