@cryptotaxi247 / kubo / commits / 6359dc9d5

update libp2p with go-multiaddr and go-stream-muxer updates

License: MIT Signed-off-by: Jeromy <why@ipfs.io>

Jeromy committed May 10, 2016 at 16:06 UTC 6359dc9d5e271be68a3a2f13e74e77c4905e83ec
117 files changed +171 -5924
Godeps/_workspace/src/github.com/codegangsta/cli/.travis.yml deleted
-18
@@ -1,18 +0,0 @@
1 -language: go
2 -sudo: false
3 -
4 -go:
5 -- 1.1.2
6 -- 1.2.2
7 -- 1.3.3
8 -- 1.4.2
9 -- 1.5.1
10 -- tip
11 -
12 -matrix:
13 - allow_failures:
14 - - go: tip
15 -
16 -script:
17 -- go vet ./...
18 -- go test -v ./...
Godeps/_workspace/src/github.com/codegangsta/cli/LICENSE deleted
-21
@@ -1,21 +0,0 @@
1 -Copyright (C) 2013 Jeremy Saenz
2 -All Rights Reserved.
3 -
4 -MIT LICENSE
5 -
6 -Permission is hereby granted, free of charge, to any person obtaining a copy of
7 -this software and associated documentation files (the "Software"), to deal in
8 -the Software without restriction, including without limitation the rights to
9 -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10 -the Software, and to permit persons to whom the Software is furnished to do so,
11 -subject to the following conditions:
12 -
13 -The above copyright notice and this permission notice shall be included in all
14 -copies or substantial portions of the Software.
15 -
16 -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18 -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19 -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20 -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Godeps/_workspace/src/github.com/codegangsta/cli/README.md deleted
-394
@@ -1,394 +0,0 @@
1 -[![Coverage](http://gocover.io/_badge/github.com/codegangsta/cli?0)](http://gocover.io/github.com/codegangsta/cli)
2 -[![Build Status](https://travis-ci.org/codegangsta/cli.svg?branch=master)](https://travis-ci.org/codegangsta/cli)
3 -[![GoDoc](https://godoc.org/github.com/codegangsta/cli?status.svg)](https://godoc.org/github.com/codegangsta/cli)
4 -
5 -# cli.go
6 -
7 -`cli.go` is simple, fast, and fun package for building command line apps in Go. The goal is to enable developers to write fast and distributable command line applications in an expressive way.
8 -
9 -## Overview
10 -
11 -Command line apps are usually so tiny that there is absolutely no reason why your code should *not* be self-documenting. Things like generating help text and parsing command flags/options should not hinder productivity when writing a command line app.
12 -
13 -**This is where `cli.go` comes into play.** `cli.go` makes command line programming fun, organized, and expressive!
14 -
15 -## Installation
16 -
17 -Make sure you have a working Go environment (go 1.1+ is *required*). [See the install instructions](http://golang.org/doc/install.html).
18 -
19 -To install `cli.go`, simply run:
20 -```
21 -$ go get github.com/codegangsta/cli
22 -```
23 -
24 -Make sure your `PATH` includes to the `$GOPATH/bin` directory so your commands can be easily used:
25 -```
26 -export PATH=$PATH:$GOPATH/bin
27 -```
28 -
29 -## Getting Started
30 -
31 -One of the philosophies behind `cli.go` is that an API should be playful and full of discovery. So a `cli.go` app can be as little as one line of code in `main()`.
32 -
33 -``` go
34 -package main
35 -
36 -import (
37 - "os"
38 - "github.com/codegangsta/cli"
39 -)
40 -
41 -func main() {
42 - cli.NewApp().Run(os.Args)
43 -}
44 -```
45 -
46 -This app will run and show help text, but is not very useful. Let's give an action to execute and some help documentation:
47 -
48 -``` go
49 -package main
50 -
51 -import (
52 - "os"
53 - "github.com/codegangsta/cli"
54 -)
55 -
56 -func main() {
57 - app := cli.NewApp()
58 - app.Name = "boom"
59 - app.Usage = "make an explosive entrance"
60 - app.Action = func(c *cli.Context) {
61 - println("boom! I say!")
62 - }
63 -
64 - app.Run(os.Args)
65 -}
66 -```
67 -
68 -Running this already gives you a ton of functionality, plus support for things like subcommands and flags, which are covered below.
69 -
70 -## Example
71 -
72 -Being a programmer can be a lonely job. Thankfully by the power of automation that is not the case! Let's create a greeter app to fend off our demons of loneliness!
73 -
74 -Start by creating a directory named `greet`, and within it, add a file, `greet.go` with the following code in it:
75 -
76 -``` go
77 -package main
78 -
79 -import (
80 - "os"
81 - "github.com/codegangsta/cli"
82 -)
83 -
84 -func main() {
85 - app := cli.NewApp()
86 - app.Name = "greet"
87 - app.Usage = "fight the loneliness!"
88 - app.Action = func(c *cli.Context) {
89 - println("Hello friend!")
90 - }
91 -
92 - app.Run(os.Args)
93 -}
94 -```
95 -
96 -Install our command to the `$GOPATH/bin` directory:
97 -
98 -```
99 -$ go install
100 -```
101 -
102 -Finally run our new command:
103 -
104 -```
105 -$ greet
106 -Hello friend!
107 -```
108 -
109 -`cli.go` also generates neat help text:
110 -
111 -```
112 -$ greet help
113 -NAME:
114 - greet - fight the loneliness!
115 -
116 -USAGE:
117 - greet [global options] command [command options] [arguments...]
118 -
119 -VERSION:
120 - 0.0.0
121 -
122 -COMMANDS:
123 - help, h Shows a list of commands or help for one command
124 -
125 -GLOBAL OPTIONS
126 - --version Shows version information
127 -```
128 -
129 -### Arguments
130 -
131 -You can lookup arguments by calling the `Args` function on `cli.Context`.
132 -
133 -``` go
134 -...
135 -app.Action = func(c *cli.Context) {
136 - println("Hello", c.Args()[0])
137 -}
138 -...
139 -```
140 -
141 -### Flags
142 -
143 -Setting and querying flags is simple.
144 -
145 -``` go
146 -...
147 -app.Flags = []cli.Flag {
148 - cli.StringFlag{
149 - Name: "lang",
150 - Value: "english",
151 - Usage: "language for the greeting",
152 - },
153 -}
154 -app.Action = func(c *cli.Context) {
155 - name := "someone"
156 - if c.NArg() > 0 {
157 - name = c.Args()[0]
158 - }
159 - if c.String("lang") == "spanish" {
160 - println("Hola", name)
161 - } else {
162 - println("Hello", name)
163 - }
164 -}
165 -...
166 -```
167 -
168 -You can also set a destination variable for a flag, to which the content will be scanned.
169 -
170 -``` go
171 -...
172 -var language string
173 -app.Flags = []cli.Flag {
174 - cli.StringFlag{
175 - Name: "lang",
176 - Value: "english",
177 - Usage: "language for the greeting",
178 - Destination: &language,
179 - },
180 -}
181 -app.Action = func(c *cli.Context) {
182 - name := "someone"
183 - if c.NArg() > 0 {
184 - name = c.Args()[0]
185 - }
186 - if language == "spanish" {
187 - println("Hola", name)
188 - } else {
189 - println("Hello", name)
190 - }
191 -}
192 -...
193 -```
194 -
195 -See full list of flags at http://godoc.org/github.com/codegangsta/cli
196 -
197 -#### Alternate Names
198 -
199 -You can set alternate (or short) names for flags by providing a comma-delimited list for the `Name`. e.g.
200 -
201 -``` go
202 -app.Flags = []cli.Flag {
203 - cli.StringFlag{
204 - Name: "lang, l",
205 - Value: "english",
206 - Usage: "language for the greeting",
207 - },
208 -}
209 -```
210 -
211 -That flag can then be set with `--lang spanish` or `-l spanish`. Note that giving two different forms of the same flag in the same command invocation is an error.
212 -
213 -#### Values from the Environment
214 -
215 -You can also have the default value set from the environment via `EnvVar`. e.g.
216 -
217 -``` go
218 -app.Flags = []cli.Flag {
219 - cli.StringFlag{
220 - Name: "lang, l",
221 - Value: "english",
222 - Usage: "language for the greeting",
223 - EnvVar: "APP_LANG",
224 - },
225 -}
226 -```
227 -
228 -The `EnvVar` may also be given as a comma-delimited "cascade", where the first environment variable that resolves is used as the default.
229 -
230 -``` go
231 -app.Flags = []cli.Flag {
232 - cli.StringFlag{
233 - Name: "lang, l",
234 - Value: "english",
235 - Usage: "language for the greeting",
236 - EnvVar: "LEGACY_COMPAT_LANG,APP_LANG,LANG",
237 - },
238 -}
239 -```
240 -
241 -#### Values from alternate input sources (YAML and others)
242 -
243 -There is a separate package altsrc that adds support for getting flag values from other input sources like YAML.
244 -
245 -In order to get values for a flag from an alternate input source the following code would be added to wrap an existing cli.Flag like below:
246 -
247 -``` go
248 - altsrc.NewIntFlag(cli.IntFlag{Name: "test"})
249 -```
250 -
251 -Initialization must also occur for these flags. Below is an example initializing getting data from a yaml file below.
252 -
253 -``` go
254 - command.Before = altsrc.InitInputSourceWithContext(command.Flags, NewYamlSourceFromFlagFunc("load"))
255 -```
256 -
257 -The code above will use the "load" string as a flag name to get the file name of a yaml file from the cli.Context.
258 -It will then use that file name to initialize the yaml input source for any flags that are defined on that command.
259 -As a note the "load" flag used would also have to be defined on the command flags in order for this code snipped to work.
260 -
261 -Currently only YAML files are supported but developers can add support for other input sources by implementing the
262 -altsrc.InputSourceContext for their given sources.
263 -
264 -Here is a more complete sample of a command using YAML support:
265 -
266 -``` go
267 - command := &cli.Command{
268 - Name: "test-cmd",
269 - Aliases: []string{"tc"},
270 - Usage: "this is for testing",
271 - Description: "testing",
272 - Action: func(c *cli.Context) {
273 - // Action to run
274 - },
275 - Flags: []cli.Flag{
276 - NewIntFlag(cli.IntFlag{Name: "test"}),
277 - cli.StringFlag{Name: "load"}},
278 - }
279 - command.Before = InitInputSourceWithContext(command.Flags, NewYamlSourceFromFlagFunc("load"))
280 - err := command.Run(c)
281 -```
282 -
283 -### Subcommands
284 -
285 -Subcommands can be defined for a more git-like command line app.
286 -
287 -```go
288 -...
289 -app.Commands = []cli.Command{
290 - {
291 - Name: "add",
292 - Aliases: []string{"a"},
293 - Usage: "add a task to the list",
294 - Action: func(c *cli.Context) {
295 - println("added task: ", c.Args().First())
296 - },
297 - },
298 - {
299 - Name: "complete",
300 - Aliases: []string{"c"},
301 - Usage: "complete a task on the list",
302 - Action: func(c *cli.Context) {
303 - println("completed task: ", c.Args().First())
304 - },
305 - },
306 - {
307 - Name: "template",
308 - Aliases: []string{"r"},
309 - Usage: "options for task templates",
310 - Subcommands: []cli.Command{
311 - {
312 - Name: "add",
313 - Usage: "add a new template",
314 - Action: func(c *cli.Context) {
315 - println("new task template: ", c.Args().First())
316 - },
317 - },
318 - {
319 - Name: "remove",
320 - Usage: "remove an existing template",
321 - Action: func(c *cli.Context) {
322 - println("removed task template: ", c.Args().First())
323 - },
324 - },
325 - },
326 - },
327 -}
328 -...
329 -```
330 -
331 -### Bash Completion
332 -
333 -You can enable completion commands by setting the `EnableBashCompletion`
334 -flag on the `App` object. By default, this setting will only auto-complete to
335 -show an app's subcommands, but you can write your own completion methods for
336 -the App or its subcommands.
337 -
338 -```go
339 -...
340 -var tasks = []string{"cook", "clean", "laundry", "eat", "sleep", "code"}
341 -app := cli.NewApp()
342 -app.EnableBashCompletion = true
343 -app.Commands = []cli.Command{
344 - {
345 - Name: "complete",
346 - Aliases: []string{"c"},
347 - Usage: "complete a task on the list",
348 - Action: func(c *cli.Context) {
349 - println("completed task: ", c.Args().First())
350 - },
351 - BashComplete: func(c *cli.Context) {
352 - // This will complete if no args are passed
353 - if c.NArg() > 0 {
354 - return
355 - }
356 - for _, t := range tasks {
357 - fmt.Println(t)
358 - }
359 - },
360 - }
361 -}
362 -...
363 -```
364 -
365 -#### To Enable
366 -
367 -Source the `autocomplete/bash_autocomplete` file in your `.bashrc` file while
368 -setting the `PROG` variable to the name of your program:
369 -
370 -`PROG=myprogram source /.../cli/autocomplete/bash_autocomplete`
371 -
372 -#### To Distribute
373 -
374 -Copy `autocomplete/bash_autocomplete` into `/etc/bash_completion.d/` and rename
375 -it to the name of the program you wish to add autocomplete support for (or
376 -automatically install it there if you are distributing a package). Don't forget
377 -to source the file to make it active in the current shell.
378 -
379 -```
380 -sudo cp src/bash_autocomplete /etc/bash_completion.d/<myprogram>
381 -source /etc/bash_completion.d/<myprogram>
382 -```
383 -
384 -Alternatively, you can just document that users should source the generic
385 -`autocomplete/bash_autocomplete` in their bash configuration with `$PROG` set
386 -to the name of their program (as above).
387 -
388 -## Contribution Guidelines
389 -
390 -Feel free to put up a pull request to fix a bug or maybe add a feature. I will give it a code review and make sure that it does not break backwards compatibility. If I or any other collaborators agree that it is in line with the vision of the project, we will work with you to get the code into a mergeable state and merge it into the master branch.
391 -
392 -If you have contributed something significant to the project, I will most likely add you as a collaborator. As a collaborator you are given the ability to merge others pull requests. It is very important that new code does not break existing code, so be careful about what code you do choose to merge. If you have any questions feel free to link @codegangsta to the issue in question and we can review it together.
393 -
394 -If you feel like you have contributed to the project but have not yet been added as a collaborator, I probably forgot to add you. Hit @codegangsta up over email and we will get it figured out.
Godeps/_workspace/src/github.com/codegangsta/cli/altsrc/flag.go deleted
-439
@@ -1,439 +0,0 @@
1 -package altsrc
2 -
3 -import (
4 - "flag"
5 - "fmt"
6 - "os"
7 - "strconv"
8 - "strings"
9 -
10 - "github.com/codegangsta/cli"
11 -)
12 -
13 -// FlagInputSourceExtension is an extension interface of cli.Flag that
14 -// allows a value to be set on the existing parsed flags.
15 -type FlagInputSourceExtension interface {
16 - cli.Flag
17 - ApplyInputSourceValue(context *cli.Context, isc InputSourceContext) error
18 -}
19 -
20 -// ApplyInputSourceValues iterates over all provided flags and
21 -// executes ApplyInputSourceValue on flags implementing the
22 -// FlagInputSourceExtension interface to initialize these flags
23 -// to an alternate input source.
24 -func ApplyInputSourceValues(context *cli.Context, inputSourceContext InputSourceContext, flags []cli.Flag) error {
25 - for _, f := range flags {
26 - inputSourceExtendedFlag, isType := f.(FlagInputSourceExtension)
27 - if isType {
28 - err := inputSourceExtendedFlag.ApplyInputSourceValue(context, inputSourceContext)
29 - if err != nil {
30 - return err
31 - }
32 - }
33 - }
34 -
35 - return nil
36 -}
37 -
38 -// InitInputSource is used to to setup an InputSourceContext on a cli.Command Before method. It will create a new
39 -// input source based on the func provided. If there is no error it will then apply the new input source to any flags
40 -// that are supported by the input source
41 -func InitInputSource(flags []cli.Flag, createInputSource func() (InputSourceContext, error)) func(context *cli.Context) error {
42 - return func(context *cli.Context) error {
43 - inputSource, err := createInputSource()
44 - if err != nil {
45 - return fmt.Errorf("Unable to create input source: inner error: \n'%v'", err.Error())
46 - }
47 -
48 - return ApplyInputSourceValues(context, inputSource, flags)
49 - }
50 -}
51 -
52 -// InitInputSourceWithContext is used to to setup an InputSourceContext on a cli.Command Before method. It will create a new
53 -// input source based on the func provided with potentially using existing cli.Context values to initialize itself. If there is
54 -// no error it will then apply the new input source to any flags that are supported by the input source
55 -func InitInputSourceWithContext(flags []cli.Flag, createInputSource func(context *cli.Context) (InputSourceContext, error)) func(context *cli.Context) error {
56 - return func(context *cli.Context) error {
57 - inputSource, err := createInputSource(context)
58 - if err != nil {
59 - return fmt.Errorf("Unable to create input source with context: inner error: \n'%v'", err.Error())
60 - }
61 -
62 - return ApplyInputSourceValues(context, inputSource, flags)
63 - }
64 -}
65 -
66 -// GenericFlag is the flag type that wraps cli.GenericFlag to allow
67 -// for other values to be specified
68 -type GenericFlag struct {
69 - cli.GenericFlag
70 - set *flag.FlagSet
71 -}
72 -
73 -// NewGenericFlag creates a new GenericFlag
74 -func NewGenericFlag(flag cli.GenericFlag) *GenericFlag {
75 - return &GenericFlag{GenericFlag: flag, set: nil}
76 -}
77 -
78 -// ApplyInputSourceValue applies a generic value to the flagSet if required
79 -func (f *GenericFlag) ApplyInputSourceValue(context *cli.Context, isc InputSourceContext) error {
80 - if f.set != nil {
81 - if !context.IsSet(f.Name) && !isEnvVarSet(f.EnvVar) {
82 - value, err := isc.Generic(f.GenericFlag.Name)
83 - if err != nil {
84 - return err
85 - }
86 - if value != nil {
87 - eachName(f.Name, func(name string) {
88 - f.set.Set(f.Name, value.String())
89 - })
90 - }
91 - }
92 - }
93 -
94 - return nil
95 -}
96 -
97 -// Apply saves the flagSet for later usage then calls
98 -// the wrapped GenericFlag.Apply
99 -func (f *GenericFlag) Apply(set *flag.FlagSet) {
100 - f.set = set
101 - f.GenericFlag.Apply(set)
102 -}
103 -
104 -// StringSliceFlag is the flag type that wraps cli.StringSliceFlag to allow
105 -// for other values to be specified
106 -type StringSliceFlag struct {
107 - cli.StringSliceFlag
108 - set *flag.FlagSet
109 -}
110 -
111 -// NewStringSliceFlag creates a new StringSliceFlag
112 -func NewStringSliceFlag(flag cli.StringSliceFlag) *StringSliceFlag {
113 - return &StringSliceFlag{StringSliceFlag: flag, set: nil}
114 -}
115 -
116 -// ApplyInputSourceValue applies a StringSlice value to the flagSet if required
117 -func (f *StringSliceFlag) ApplyInputSourceValue(context *cli.Context, isc InputSourceContext) error {
118 - if f.set != nil {
119 - if !context.IsSet(f.Name) && !isEnvVarSet(f.EnvVar) {
120 - value, err := isc.StringSlice(f.StringSliceFlag.Name)
121 - if err != nil {
122 - return err
123 - }
124 - if value != nil {
125 - var sliceValue cli.StringSlice = value
126 - eachName(f.Name, func(name string) {
127 - underlyingFlag := f.set.Lookup(f.Name)
128 - if underlyingFlag != nil {
129 - underlyingFlag.Value = &sliceValue
130 - }
131 - })
132 - }
133 - }
134 - }
135 - return nil
136 -}
137 -
138 -// Apply saves the flagSet for later usage then calls
139 -// the wrapped StringSliceFlag.Apply
140 -func (f *StringSliceFlag) Apply(set *flag.FlagSet) {
141 - f.set = set
142 - f.StringSliceFlag.Apply(set)
143 -}
144 -
145 -// IntSliceFlag is the flag type that wraps cli.IntSliceFlag to allow
146 -// for other values to be specified
147 -type IntSliceFlag struct {
148 - cli.IntSliceFlag
149 - set *flag.FlagSet
150 -}
151 -
152 -// NewIntSliceFlag creates a new IntSliceFlag
153 -func NewIntSliceFlag(flag cli.IntSliceFlag) *IntSliceFlag {
154 - return &IntSliceFlag{IntSliceFlag: flag, set: nil}
155 -}
156 -
157 -// ApplyInputSourceValue applies a IntSlice value if required
158 -func (f *IntSliceFlag) ApplyInputSourceValue(context *cli.Context, isc InputSourceContext) error {
159 - if f.set != nil {
160 - if !context.IsSet(f.Name) && !isEnvVarSet(f.EnvVar) {
161 - value, err := isc.IntSlice(f.IntSliceFlag.Name)
162 - if err != nil {
163 - return err
164 - }
165 - if value != nil {
166 - var sliceValue cli.IntSlice = value
167 - eachName(f.Name, func(name string) {
168 - underlyingFlag := f.set.Lookup(f.Name)
169 - if underlyingFlag != nil {
170 - underlyingFlag.Value = &sliceValue
171 - }
172 - })
173 - }
174 - }
175 - }
176 - return nil
177 -}
178 -
179 -// Apply saves the flagSet for later usage then calls
180 -// the wrapped IntSliceFlag.Apply
181 -func (f *IntSliceFlag) Apply(set *flag.FlagSet) {
182 - f.set = set
183 - f.IntSliceFlag.Apply(set)
184 -}
185 -
186 -// BoolFlag is the flag type that wraps cli.BoolFlag to allow
187 -// for other values to be specified
188 -type BoolFlag struct {
189 - cli.BoolFlag
190 - set *flag.FlagSet
191 -}
192 -
193 -// NewBoolFlag creates a new BoolFlag
194 -func NewBoolFlag(flag cli.BoolFlag) *BoolFlag {
195 - return &BoolFlag{BoolFlag: flag, set: nil}
196 -}
197 -
198 -// ApplyInputSourceValue applies a Bool value to the flagSet if required
199 -func (f *BoolFlag) ApplyInputSourceValue(context *cli.Context, isc InputSourceContext) error {
200 - if f.set != nil {
201 - if !context.IsSet(f.Name) && !isEnvVarSet(f.EnvVar) {
202 - value, err := isc.Bool(f.BoolFlag.Name)
203 - if err != nil {
204 - return err
205 - }
206 - if value {
207 - eachName(f.Name, func(name string) {
208 - f.set.Set(f.Name, strconv.FormatBool(value))
209 - })
210 - }
211 - }
212 - }
213 - return nil
214 -}
215 -
216 -// Apply saves the flagSet for later usage then calls
217 -// the wrapped BoolFlag.Apply
218 -func (f *BoolFlag) Apply(set *flag.FlagSet) {
219 - f.set = set
220 - f.BoolFlag.Apply(set)
221 -}
222 -
223 -// BoolTFlag is the flag type that wraps cli.BoolTFlag to allow
224 -// for other values to be specified
225 -type BoolTFlag struct {
226 - cli.BoolTFlag
227 - set *flag.FlagSet
228 -}
229 -
230 -// NewBoolTFlag creates a new BoolTFlag
231 -func NewBoolTFlag(flag cli.BoolTFlag) *BoolTFlag {
232 - return &BoolTFlag{BoolTFlag: flag, set: nil}
233 -}
234 -
235 -// ApplyInputSourceValue applies a BoolT value to the flagSet if required
236 -func (f *BoolTFlag) ApplyInputSourceValue(context *cli.Context, isc InputSourceContext) error {
237 - if f.set != nil {
238 - if !context.IsSet(f.Name) && !isEnvVarSet(f.EnvVar) {
239 - value, err := isc.BoolT(f.BoolTFlag.Name)
240 - if err != nil {
241 - return err
242 - }
243 - if !value {
244 - eachName(f.Name, func(name string) {
245 - f.set.Set(f.Name, strconv.FormatBool(value))
246 - })
247 - }
248 - }
249 - }
250 - return nil
251 -}
252 -
253 -// Apply saves the flagSet for later usage then calls
254 -// the wrapped BoolTFlag.Apply
255 -func (f *BoolTFlag) Apply(set *flag.FlagSet) {
256 - f.set = set
257 -
258 - f.BoolTFlag.Apply(set)
259 -}
260 -
261 -// StringFlag is the flag type that wraps cli.StringFlag to allow
262 -// for other values to be specified
263 -type StringFlag struct {
264 - cli.StringFlag
265 - set *flag.FlagSet
266 -}
267 -
268 -// NewStringFlag creates a new StringFlag
269 -func NewStringFlag(flag cli.StringFlag) *StringFlag {
270 - return &StringFlag{StringFlag: flag, set: nil}
271 -}
272 -
273 -// ApplyInputSourceValue applies a String value to the flagSet if required
274 -func (f *StringFlag) ApplyInputSourceValue(context *cli.Context, isc InputSourceContext) error {
275 - if f.set != nil {
276 - if !(context.IsSet(f.Name) || isEnvVarSet(f.EnvVar)) {
277 - value, err := isc.String(f.StringFlag.Name)
278 - if err != nil {
279 - return err
280 - }
281 - if value != "" {
282 - eachName(f.Name, func(name string) {
283 - f.set.Set(f.Name, value)
284 - })
285 - }
286 - }
287 - }
288 - return nil
289 -}
290 -
291 -// Apply saves the flagSet for later usage then calls
292 -// the wrapped StringFlag.Apply
293 -func (f *StringFlag) Apply(set *flag.FlagSet) {
294 - f.set = set
295 -
296 - f.StringFlag.Apply(set)
297 -}
298 -
299 -// IntFlag is the flag type that wraps cli.IntFlag to allow
300 -// for other values to be specified
301 -type IntFlag struct {
302 - cli.IntFlag
303 - set *flag.FlagSet
304 -}
305 -
306 -// NewIntFlag creates a new IntFlag
307 -func NewIntFlag(flag cli.IntFlag) *IntFlag {
308 - return &IntFlag{IntFlag: flag, set: nil}
309 -}
310 -
311 -// ApplyInputSourceValue applies a int value to the flagSet if required
312 -func (f *IntFlag) ApplyInputSourceValue(context *cli.Context, isc InputSourceContext) error {
313 - if f.set != nil {
314 - if !(context.IsSet(f.Name) || isEnvVarSet(f.EnvVar)) {
315 - value, err := isc.Int(f.IntFlag.Name)
316 - if err != nil {
317 - return err
318 - }
319 - if value > 0 {
320 - eachName(f.Name, func(name string) {
321 - f.set.Set(f.Name, strconv.FormatInt(int64(value), 10))
322 - })
323 - }
324 - }
325 - }
326 - return nil
327 -}
328 -
329 -// Apply saves the flagSet for later usage then calls
330 -// the wrapped IntFlag.Apply
331 -func (f *IntFlag) Apply(set *flag.FlagSet) {
332 - f.set = set
333 - f.IntFlag.Apply(set)
334 -}
335 -
336 -// DurationFlag is the flag type that wraps cli.DurationFlag to allow
337 -// for other values to be specified
338 -type DurationFlag struct {
339 - cli.DurationFlag
340 - set *flag.FlagSet
341 -}
342 -
343 -// NewDurationFlag creates a new DurationFlag
344 -func NewDurationFlag(flag cli.DurationFlag) *DurationFlag {
345 - return &DurationFlag{DurationFlag: flag, set: nil}
346 -}
347 -
348 -// ApplyInputSourceValue applies a Duration value to the flagSet if required
349 -func (f *DurationFlag) ApplyInputSourceValue(context *cli.Context, isc InputSourceContext) error {
350 - if f.set != nil {
351 - if !(context.IsSet(f.Name) || isEnvVarSet(f.EnvVar)) {
352 - value, err := isc.Duration(f.DurationFlag.Name)
353 - if err != nil {
354 - return err
355 - }
356 - if value > 0 {
357 - eachName(f.Name, func(name string) {
358 - f.set.Set(f.Name, value.String())
359 - })
360 - }
361 - }
362 - }
363 - return nil
364 -}
365 -
366 -// Apply saves the flagSet for later usage then calls
367 -// the wrapped DurationFlag.Apply
368 -func (f *DurationFlag) Apply(set *flag.FlagSet) {
369 - f.set = set
370 -
371 - f.DurationFlag.Apply(set)
372 -}
373 -
374 -// Float64Flag is the flag type that wraps cli.Float64Flag to allow
375 -// for other values to be specified
376 -type Float64Flag struct {
377 - cli.Float64Flag
378 - set *flag.FlagSet
379 -}
380 -
381 -// NewFloat64Flag creates a new Float64Flag
382 -func NewFloat64Flag(flag cli.Float64Flag) *Float64Flag {
383 - return &Float64Flag{Float64Flag: flag, set: nil}
384 -}
385 -
386 -// ApplyInputSourceValue applies a Float64 value to the flagSet if required
387 -func (f *Float64Flag) ApplyInputSourceValue(context *cli.Context, isc InputSourceContext) error {
388 - if f.set != nil {
389 - if !(context.IsSet(f.Name) || isEnvVarSet(f.EnvVar)) {
390 - value, err := isc.Float64(f.Float64Flag.Name)
391 - if err != nil {
392 - return err
393 - }
394 - if value > 0 {
395 - floatStr := float64ToString(value)
396 - eachName(f.Name, func(name string) {
397 - f.set.Set(f.Name, floatStr)
398 - })
399 - }
400 - }
401 - }
402 - return nil
403 -}
404 -
405 -// Apply saves the flagSet for later usage then calls
406 -// the wrapped Float64Flag.Apply
407 -func (f *Float64Flag) Apply(set *flag.FlagSet) {
408 - f.set = set
409 -
410 - f.Float64Flag.Apply(set)
411 -}
412 -
413 -func isEnvVarSet(envVars string) bool {
414 - for _, envVar := range strings.Split(envVars, ",") {
415 - envVar = strings.TrimSpace(envVar)
416 - if envVal := os.Getenv(envVar); envVal != "" {
417 - // TODO: Can't use this for bools as
418 - // set means that it was true or false based on
419 - // Bool flag type, should work for other types
420 - if len(envVal) > 0 {
421 - return true
422 - }
423 - }
424 - }
425 -
426 - return false
427 -}
428 -
429 -func float64ToString(f float64) string {
430 - return fmt.Sprintf("%v", f)
431 -}
432 -
433 -func eachName(longName string, fn func(string)) {
434 - parts := strings.Split(longName, ",")
435 - for _, name := range parts {
436 - name = strings.Trim(name, " ")
437 - fn(name)
438 - }
439 -}
Godeps/_workspace/src/github.com/codegangsta/cli/altsrc/flag_test.go deleted
-336
@@ -1,336 +0,0 @@
1 -package altsrc
2 -
3 -import (
4 - "flag"
5 - "fmt"
6 - "os"
7 - "strings"
8 - "testing"
9 - "time"
10 -
11 - "github.com/codegangsta/cli"
12 -)
13 -
14 -type testApplyInputSource struct {
15 - Flag FlagInputSourceExtension
16 - FlagName string
17 - FlagSetName string
18 - Expected string
19 - ContextValueString string
20 - ContextValue flag.Value
21 - EnvVarValue string
22 - EnvVarName string
23 - MapValue interface{}
24 -}
25 -
26 -func TestGenericApplyInputSourceValue(t *testing.T) {
27 - v := &Parser{"abc", "def"}
28 - c := runTest(t, testApplyInputSource{
29 - Flag: NewGenericFlag(cli.GenericFlag{Name: "test", Value: &Parser{}}),
30 - FlagName: "test",
31 - MapValue: v,
32 - })
33 - expect(t, v, c.Generic("test"))
34 -}
35 -
36 -func TestGenericApplyInputSourceMethodContextSet(t *testing.T) {
37 - p := &Parser{"abc", "def"}
38 - c := runTest(t, testApplyInputSource{
39 - Flag: NewGenericFlag(cli.GenericFlag{Name: "test", Value: &Parser{}}),
40 - FlagName: "test",
41 - MapValue: &Parser{"efg", "hig"},
42 - ContextValueString: p.String(),
43 - })
44 - expect(t, p, c.Generic("test"))
45 -}
46 -
47 -func TestGenericApplyInputSourceMethodEnvVarSet(t *testing.T) {
48 - c := runTest(t, testApplyInputSource{
49 - Flag: NewGenericFlag(cli.GenericFlag{Name: "test", Value: &Parser{}, EnvVar: "TEST"}),
50 - FlagName: "test",
51 - MapValue: &Parser{"efg", "hij"},
52 - EnvVarName: "TEST",
53 - EnvVarValue: "abc,def",
54 - })
55 - expect(t, &Parser{"abc", "def"}, c.Generic("test"))
56 -}
57 -
58 -func TestStringSliceApplyInputSourceValue(t *testing.T) {
59 - c := runTest(t, testApplyInputSource{
60 - Flag: NewStringSliceFlag(cli.StringSliceFlag{Name: "test"}),
61 - FlagName: "test",
62 - MapValue: []string{"hello", "world"},
63 - })
64 - expect(t, c.StringSlice("test"), []string{"hello", "world"})
65 -}
66 -
67 -func TestStringSliceApplyInputSourceMethodContextSet(t *testing.T) {
68 - c := runTest(t, testApplyInputSource{
69 - Flag: NewStringSliceFlag(cli.StringSliceFlag{Name: "test"}),
70 - FlagName: "test",
71 - MapValue: []string{"hello", "world"},
72 - ContextValueString: "ohno",
73 - })
74 - expect(t, c.StringSlice("test"), []string{"ohno"})
75 -}
76 -
77 -func TestStringSliceApplyInputSourceMethodEnvVarSet(t *testing.T) {
78 - c := runTest(t, testApplyInputSource{
79 - Flag: NewStringSliceFlag(cli.StringSliceFlag{Name: "test", EnvVar: "TEST"}),
80 - FlagName: "test",
81 - MapValue: []string{"hello", "world"},
82 - EnvVarName: "TEST",
83 - EnvVarValue: "oh,no",
84 - })
85 - expect(t, c.StringSlice("test"), []string{"oh", "no"})
86 -}
87 -
88 -func TestIntSliceApplyInputSourceValue(t *testing.T) {
89 - c := runTest(t, testApplyInputSource{
90 - Flag: NewIntSliceFlag(cli.IntSliceFlag{Name: "test"}),
91 - FlagName: "test",
92 - MapValue: []int{1, 2},
93 - })
94 - expect(t, c.IntSlice("test"), []int{1, 2})
95 -}
96 -
97 -func TestIntSliceApplyInputSourceMethodContextSet(t *testing.T) {
98 - c := runTest(t, testApplyInputSource{
99 - Flag: NewIntSliceFlag(cli.IntSliceFlag{Name: "test"}),
100 - FlagName: "test",
101 - MapValue: []int{1, 2},
102 - ContextValueString: "3",
103 - })
104 - expect(t, c.IntSlice("test"), []int{3})
105 -}
106 -
107 -func TestIntSliceApplyInputSourceMethodEnvVarSet(t *testing.T) {
108 - c := runTest(t, testApplyInputSource{
109 - Flag: NewIntSliceFlag(cli.IntSliceFlag{Name: "test", EnvVar: "TEST"}),
110 - FlagName: "test",
111 - MapValue: []int{1, 2},
112 - EnvVarName: "TEST",
113 - EnvVarValue: "3,4",
114 - })
115 - expect(t, c.IntSlice("test"), []int{3, 4})
116 -}
117 -
118 -func TestBoolApplyInputSourceMethodSet(t *testing.T) {
119 - c := runTest(t, testApplyInputSource{
120 - Flag: NewBoolFlag(cli.BoolFlag{Name: "test"}),
121 - FlagName: "test",
122 - MapValue: true,
123 - })
124 - expect(t, true, c.Bool("test"))
125 -}
126 -
127 -func TestBoolApplyInputSourceMethodContextSet(t *testing.T) {
128 - c := runTest(t, testApplyInputSource{
129 - Flag: NewBoolFlag(cli.BoolFlag{Name: "test"}),
130 - FlagName: "test",
131 - MapValue: false,
132 - ContextValueString: "true",
133 - })
134 - expect(t, true, c.Bool("test"))
135 -}
136 -
137 -func TestBoolApplyInputSourceMethodEnvVarSet(t *testing.T) {
138 - c := runTest(t, testApplyInputSource{
139 - Flag: NewBoolFlag(cli.BoolFlag{Name: "test", EnvVar: "TEST"}),
140 - FlagName: "test",
141 - MapValue: false,
142 - EnvVarName: "TEST",
143 - EnvVarValue: "true",
144 - })
145 - expect(t, true, c.Bool("test"))
146 -}
147 -
148 -func TestBoolTApplyInputSourceMethodSet(t *testing.T) {
149 - c := runTest(t, testApplyInputSource{
150 - Flag: NewBoolTFlag(cli.BoolTFlag{Name: "test"}),
151 - FlagName: "test",
152 - MapValue: false,
153 - })
154 - expect(t, false, c.BoolT("test"))
155 -}
156 -
157 -func TestBoolTApplyInputSourceMethodContextSet(t *testing.T) {
158 - c := runTest(t, testApplyInputSource{
159 - Flag: NewBoolTFlag(cli.BoolTFlag{Name: "test"}),
160 - FlagName: "test",
161 - MapValue: true,
162 - ContextValueString: "false",
163 - })
164 - expect(t, false, c.BoolT("test"))
165 -}
166 -
167 -func TestBoolTApplyInputSourceMethodEnvVarSet(t *testing.T) {
168 - c := runTest(t, testApplyInputSource{
169 - Flag: NewBoolTFlag(cli.BoolTFlag{Name: "test", EnvVar: "TEST"}),
170 - FlagName: "test",
171 - MapValue: true,
172 - EnvVarName: "TEST",
173 - EnvVarValue: "false",
174 - })
175 - expect(t, false, c.BoolT("test"))
176 -}
177 -
178 -func TestStringApplyInputSourceMethodSet(t *testing.T) {
179 - c := runTest(t, testApplyInputSource{
180 - Flag: NewStringFlag(cli.StringFlag{Name: "test"}),
181 - FlagName: "test",
182 - MapValue: "hello",
183 - })
184 - expect(t, "hello", c.String("test"))
185 -}
186 -
187 -func TestStringApplyInputSourceMethodContextSet(t *testing.T) {
188 - c := runTest(t, testApplyInputSource{
189 - Flag: NewStringFlag(cli.StringFlag{Name: "test"}),
190 - FlagName: "test",
191 - MapValue: "hello",
192 - ContextValueString: "goodbye",
193 - })
194 - expect(t, "goodbye", c.String("test"))
195 -}
196 -
197 -func TestStringApplyInputSourceMethodEnvVarSet(t *testing.T) {
198 - c := runTest(t, testApplyInputSource{
199 - Flag: NewStringFlag(cli.StringFlag{Name: "test", EnvVar: "TEST"}),
200 - FlagName: "test",
201 - MapValue: "hello",
202 - EnvVarName: "TEST",
203 - EnvVarValue: "goodbye",
204 - })
205 - expect(t, "goodbye", c.String("test"))
206 -}
207 -
208 -func TestIntApplyInputSourceMethodSet(t *testing.T) {
209 - c := runTest(t, testApplyInputSource{
210 - Flag: NewIntFlag(cli.IntFlag{Name: "test"}),
211 - FlagName: "test",
212 - MapValue: 15,
213 - })
214 - expect(t, 15, c.Int("test"))
215 -}
216 -
217 -func TestIntApplyInputSourceMethodContextSet(t *testing.T) {
218 - c := runTest(t, testApplyInputSource{
219 - Flag: NewIntFlag(cli.IntFlag{Name: "test"}),
220 - FlagName: "test",
221 - MapValue: 15,
222 - ContextValueString: "7",
223 - })
224 - expect(t, 7, c.Int("test"))
225 -}
226 -
227 -func TestIntApplyInputSourceMethodEnvVarSet(t *testing.T) {
228 - c := runTest(t, testApplyInputSource{
229 - Flag: NewIntFlag(cli.IntFlag{Name: "test", EnvVar: "TEST"}),
230 - FlagName: "test",
231 - MapValue: 15,
232 - EnvVarName: "TEST",
233 - EnvVarValue: "12",
234 - })
235 - expect(t, 12, c.Int("test"))
236 -}
237 -
238 -func TestDurationApplyInputSourceMethodSet(t *testing.T) {
239 - c := runTest(t, testApplyInputSource{
240 - Flag: NewDurationFlag(cli.DurationFlag{Name: "test"}),
241 - FlagName: "test",
242 - MapValue: time.Duration(30 * time.Second),
243 - })
244 - expect(t, time.Duration(30*time.Second), c.Duration("test"))
245 -}
246 -
247 -func TestDurationApplyInputSourceMethodContextSet(t *testing.T) {
248 - c := runTest(t, testApplyInputSource{
249 - Flag: NewDurationFlag(cli.DurationFlag{Name: "test"}),
250 - FlagName: "test",
251 - MapValue: time.Duration(30 * time.Second),
252 - ContextValueString: time.Duration(15 * time.Second).String(),
253 - })
254 - expect(t, time.Duration(15*time.Second), c.Duration("test"))
255 -}
256 -
257 -func TestDurationApplyInputSourceMethodEnvVarSet(t *testing.T) {
258 - c := runTest(t, testApplyInputSource{
259 - Flag: NewDurationFlag(cli.DurationFlag{Name: "test", EnvVar: "TEST"}),
260 - FlagName: "test",
261 - MapValue: time.Duration(30 * time.Second),
262 - EnvVarName: "TEST",
263 - EnvVarValue: time.Duration(15 * time.Second).String(),
264 - })
265 - expect(t, time.Duration(15*time.Second), c.Duration("test"))
266 -}
267 -
268 -func TestFloat64ApplyInputSourceMethodSet(t *testing.T) {
269 - c := runTest(t, testApplyInputSource{
270 - Flag: NewFloat64Flag(cli.Float64Flag{Name: "test"}),
271 - FlagName: "test",
272 - MapValue: 1.3,
273 - })
274 - expect(t, 1.3, c.Float64("test"))
275 -}
276 -
277 -func TestFloat64ApplyInputSourceMethodContextSet(t *testing.T) {
278 - c := runTest(t, testApplyInputSource{
279 - Flag: NewFloat64Flag(cli.Float64Flag{Name: "test"}),
280 - FlagName: "test",
281 - MapValue: 1.3,
282 - ContextValueString: fmt.Sprintf("%v", 1.4),
283 - })
284 - expect(t, 1.4, c.Float64("test"))
285 -}
286 -
287 -func TestFloat64ApplyInputSourceMethodEnvVarSet(t *testing.T) {
288 - c := runTest(t, testApplyInputSource{
289 - Flag: NewFloat64Flag(cli.Float64Flag{Name: "test", EnvVar: "TEST"}),
290 - FlagName: "test",
291 - MapValue: 1.3,
292 - EnvVarName: "TEST",
293 - EnvVarValue: fmt.Sprintf("%v", 1.4),
294 - })
295 - expect(t, 1.4, c.Float64("test"))
296 -}
297 -
298 -func runTest(t *testing.T, test testApplyInputSource) *cli.Context {
299 - inputSource := &MapInputSource{valueMap: map[string]interface{}{test.FlagName: test.MapValue}}
300 - set := flag.NewFlagSet(test.FlagSetName, flag.ContinueOnError)
301 - c := cli.NewContext(nil, set, nil)
302 - if test.EnvVarName != "" && test.EnvVarValue != "" {
303 - os.Setenv(test.EnvVarName, test.EnvVarValue)
304 - defer os.Setenv(test.EnvVarName, "")
305 - }
306 -
307 - test.Flag.Apply(set)
308 - if test.ContextValue != nil {
309 - flag := set.Lookup(test.FlagName)
310 - flag.Value = test.ContextValue
311 - }
312 - if test.ContextValueString != "" {
313 - set.Set(test.FlagName, test.ContextValueString)
314 - }
315 - test.Flag.ApplyInputSourceValue(c, inputSource)
316 -
317 - return c
318 -}
319 -
320 -type Parser [2]string
321 -
322 -func (p *Parser) Set(value string) error {
323 - parts := strings.Split(value, ",")
324 - if len(parts) != 2 {
325 - return fmt.Errorf("invalid format")
326 - }
327 -
328 - (*p)[0] = parts[0]
329 - (*p)[1] = parts[1]
330 -
331 - return nil
332 -}
333 -
334 -func (p *Parser) String() string {
335 - return fmt.Sprintf("%s,%s", p[0], p[1])
336 -}
Godeps/_workspace/src/github.com/codegangsta/cli/altsrc/helpers_test.go deleted
-18
@@ -1,18 +0,0 @@
1 -package altsrc
2 -
3 -import (
4 - "reflect"
5 - "testing"
6 -)
7 -
8 -func expect(t *testing.T, a interface{}, b interface{}) {
9 - if !reflect.DeepEqual(b, a) {
10 - t.Errorf("Expected %#v (type %v) - Got %#v (type %v)", b, reflect.TypeOf(b), a, reflect.TypeOf(a))
11 - }
12 -}
13 -
14 -func refute(t *testing.T, a interface{}, b interface{}) {
15 - if a == b {
16 - t.Errorf("Did not expect %v (type %v) - Got %v (type %v)", b, reflect.TypeOf(b), a, reflect.TypeOf(a))
17 - }
18 -}
Godeps/_workspace/src/github.com/codegangsta/cli/altsrc/input_source_context.go deleted
-21
@@ -1,21 +0,0 @@
1 -package altsrc
2 -
3 -import (
4 - "time"
5 -
6 - "github.com/codegangsta/cli"
7 -)
8 -
9 -// InputSourceContext is an interface used to allow
10 -// other input sources to be implemented as needed.
11 -type InputSourceContext interface {
12 - Int(name string) (int, error)
13 - Duration(name string) (time.Duration, error)
14 - Float64(name string) (float64, error)
15 - String(name string) (string, error)
16 - StringSlice(name string) ([]string, error)
17 - IntSlice(name string) ([]int, error)
18 - Generic(name string) (cli.Generic, error)
19 - Bool(name string) (bool, error)
20 - BoolT(name string) (bool, error)
21 -}
Godeps/_workspace/src/github.com/codegangsta/cli/altsrc/map_input_source.go deleted
-152
@@ -1,152 +0,0 @@
1 -package altsrc
2 -
3 -import (
4 - "fmt"
5 - "reflect"
6 - "time"
7 -
8 - "github.com/codegangsta/cli"
9 -)
10 -
11 -// MapInputSource implements InputSourceContext to return
12 -// data from the map that is loaded.
13 -type MapInputSource struct {
14 - valueMap map[string]interface{}
15 -}
16 -
17 -// Int returns an int from the map if it exists otherwise returns 0
18 -func (fsm *MapInputSource) Int(name string) (int, error) {
19 - otherGenericValue, exists := fsm.valueMap[name]
20 - if exists {
21 - otherValue, isType := otherGenericValue.(int)
22 - if !isType {
23 - return 0, incorrectTypeForFlagError(name, "int", otherGenericValue)
24 - }
25 -
26 - return otherValue, nil
27 - }
28 -
29 - return 0, nil
30 -}
31 -
32 -// Duration returns a duration from the map if it exists otherwise returns 0
33 -func (fsm *MapInputSource) Duration(name string) (time.Duration, error) {
34 - otherGenericValue, exists := fsm.valueMap[name]
35 - if exists {
36 - otherValue, isType := otherGenericValue.(time.Duration)
37 - if !isType {
38 - return 0, incorrectTypeForFlagError(name, "duration", otherGenericValue)
39 - }
40 - return otherValue, nil
41 - }
42 -
43 - return 0, nil
44 -}
45 -
46 -// Float64 returns an float64 from the map if it exists otherwise returns 0
47 -func (fsm *MapInputSource) Float64(name string) (float64, error) {
48 - otherGenericValue, exists := fsm.valueMap[name]
49 - if exists {
50 - otherValue, isType := otherGenericValue.(float64)
51 - if !isType {
52 - return 0, incorrectTypeForFlagError(name, "float64", otherGenericValue)
53 - }
54 - return otherValue, nil
55 - }
56 -
57 - return 0, nil
58 -}
59 -
60 -// String returns a string from the map if it exists otherwise returns an empty string
61 -func (fsm *MapInputSource) String(name string) (string, error) {
62 - otherGenericValue, exists := fsm.valueMap[name]
63 - if exists {
64 - otherValue, isType := otherGenericValue.(string)
65 - if !isType {
66 - return "", incorrectTypeForFlagError(name, "string", otherGenericValue)
67 - }
68 - return otherValue, nil
69 - }
70 -
71 - return "", nil
72 -}
73 -
74 -// StringSlice returns an []string from the map if it exists otherwise returns nil
75 -func (fsm *MapInputSource) StringSlice(name string) ([]string, error) {
76 - otherGenericValue, exists := fsm.valueMap[name]
77 - if exists {
78 - otherValue, isType := otherGenericValue.([]string)
79 - if !isType {
80 - return nil, incorrectTypeForFlagError(name, "[]string", otherGenericValue)
81 - }
82 - return otherValue, nil
83 - }
84 -
85 - return nil, nil
86 -}
87 -
88 -// IntSlice returns an []int from the map if it exists otherwise returns nil
89 -func (fsm *MapInputSource) IntSlice(name string) ([]int, error) {
90 - otherGenericValue, exists := fsm.valueMap[name]
91 - if exists {
92 - otherValue, isType := otherGenericValue.([]int)
93 - if !isType {
94 - return nil, incorrectTypeForFlagError(name, "[]int", otherGenericValue)
95 - }
96 - return otherValue, nil
97 - }
98 -
99 - return nil, nil
100 -}
101 -
102 -// Generic returns an cli.Generic from the map if it exists otherwise returns nil
103 -func (fsm *MapInputSource) Generic(name string) (cli.Generic, error) {
104 - otherGenericValue, exists := fsm.valueMap[name]
105 - if exists {
106 - otherValue, isType := otherGenericValue.(cli.Generic)
107 - if !isType {
108 - return nil, incorrectTypeForFlagError(name, "cli.Generic", otherGenericValue)
109 - }
110 - return otherValue, nil
111 - }
112 -
113 - return nil, nil
114 -}
115 -
116 -// Bool returns an bool from the map otherwise returns false
117 -func (fsm *MapInputSource) Bool(name string) (bool, error) {
118 - otherGenericValue, exists := fsm.valueMap[name]
119 - if exists {
120 - otherValue, isType := otherGenericValue.(bool)
121 - if !isType {
122 - return false, incorrectTypeForFlagError(name, "bool", otherGenericValue)
123 - }
124 - return otherValue, nil
125 - }
126 -
127 - return false, nil
128 -}
129 -
130 -// BoolT returns an bool from the map otherwise returns true
131 -func (fsm *MapInputSource) BoolT(name string) (bool, error) {
132 - otherGenericValue, exists := fsm.valueMap[name]
133 - if exists {
134 - otherValue, isType := otherGenericValue.(bool)
135 - if !isType {
136 - return true, incorrectTypeForFlagError(name, "bool", otherGenericValue)
137 - }
138 - return otherValue, nil
139 - }
140 -
141 - return true, nil
142 -}
143 -
144 -func incorrectTypeForFlagError(name, expectedTypeName string, value interface{}) error {
145 - valueType := reflect.TypeOf(value)
146 - valueTypeName := ""
147 - if valueType != nil {
148 - valueTypeName = valueType.Name()
149 - }
150 -
151 - return fmt.Errorf("Mismatched type for flag '%s'. Expected '%s' but actual is '%s'", name, expectedTypeName, valueTypeName)
152 -}
Godeps/_workspace/src/github.com/codegangsta/cli/altsrc/yaml_command_test.go deleted
-172
@@ -1,172 +0,0 @@
1 -// Disabling building of yaml support in cases where golang is 1.0 or 1.1
2 -// as the encoding library is not implemented or supported.
3 -
4 -// +build !go1,!go1.1
5 -
6 -package altsrc
7 -
8 -import (
9 - "flag"
10 - "io/ioutil"
11 - "os"
12 - "testing"
13 -
14 - "github.com/codegangsta/cli"
15 -)
16 -
17 -func TestCommandYamlFileTest(t *testing.T) {
18 - app := cli.NewApp()
19 - set := flag.NewFlagSet("test", 0)
20 - ioutil.WriteFile("current.yaml", []byte("test: 15"), 0666)
21 - defer os.Remove("current.yaml")
22 - test := []string{"test-cmd", "--load", "current.yaml"}
23 - set.Parse(test)
24 -
25 - c := cli.NewContext(app, set, nil)
26 -
27 - command := &cli.Command{
28 - Name: "test-cmd",
29 - Aliases: []string{"tc"},
30 - Usage: "this is for testing",
31 - Description: "testing",
32 - Action: func(c *cli.Context) {
33 - val := c.Int("test")
34 - expect(t, val, 15)
35 - },
36 - Flags: []cli.Flag{
37 - NewIntFlag(cli.IntFlag{Name: "test"}),
38 - cli.StringFlag{Name: "load"}},
39 - }
40 - command.Before = InitInputSourceWithContext(command.Flags, NewYamlSourceFromFlagFunc("load"))
41 - err := command.Run(c)
42 -
43 - expect(t, err, nil)
44 -}
45 -
46 -func TestCommandYamlFileTestGlobalEnvVarWins(t *testing.T) {
47 - app := cli.NewApp()
48 - set := flag.NewFlagSet("test", 0)
49 - ioutil.WriteFile("current.yaml", []byte("test: 15"), 0666)
50 - defer os.Remove("current.yaml")
51 -
52 - os.Setenv("THE_TEST", "10")
53 - defer os.Setenv("THE_TEST", "")
54 - test := []string{"test-cmd", "--load", "current.yaml"}
55 - set.Parse(test)
56 -
57 - c := cli.NewContext(app, set, nil)
58 -
59 - command := &cli.Command{
60 - Name: "test-cmd",
61 - Aliases: []string{"tc"},
62 - Usage: "this is for testing",
63 - Description: "testing",
64 - Action: func(c *cli.Context) {
65 - val := c.Int("test")
66 - expect(t, val, 10)
67 - },
68 - Flags: []cli.Flag{
69 - NewIntFlag(cli.IntFlag{Name: "test", EnvVar: "THE_TEST"}),
70 - cli.StringFlag{Name: "load"}},
71 - }
72 - command.Before = InitInputSourceWithContext(command.Flags, NewYamlSourceFromFlagFunc("load"))
73 -
74 - err := command.Run(c)
75 -
76 - expect(t, err, nil)
77 -}
78 -
79 -func TestCommandYamlFileTestSpecifiedFlagWins(t *testing.T) {
80 - app := cli.NewApp()
81 - set := flag.NewFlagSet("test", 0)
82 - ioutil.WriteFile("current.yaml", []byte("test: 15"), 0666)
83 - defer os.Remove("current.yaml")
84 -
85 - test := []string{"test-cmd", "--load", "current.yaml", "--test", "7"}
86 - set.Parse(test)
87 -
88 - c := cli.NewContext(app, set, nil)
89 -
90 - command := &cli.Command{
91 - Name: "test-cmd",
92 - Aliases: []string{"tc"},
93 - Usage: "this is for testing",
94 - Description: "testing",
95 - Action: func(c *cli.Context) {
96 - val := c.Int("test")
97 - expect(t, val, 7)
98 - },
99 - Flags: []cli.Flag{
100 - NewIntFlag(cli.IntFlag{Name: "test"}),
101 - cli.StringFlag{Name: "load"}},
102 - }
103 - command.Before = InitInputSourceWithContext(command.Flags, NewYamlSourceFromFlagFunc("load"))
104 -
105 - err := command.Run(c)
106 -
107 - expect(t, err, nil)
108 -}
109 -
110 -func TestCommandYamlFileTestDefaultValueFileWins(t *testing.T) {
111 - app := cli.NewApp()
112 - set := flag.NewFlagSet("test", 0)
113 - ioutil.WriteFile("current.yaml", []byte("test: 15"), 0666)
114 - defer os.Remove("current.yaml")
115 -
116 - test := []string{"test-cmd", "--load", "current.yaml"}
117 - set.Parse(test)
118 -
119 - c := cli.NewContext(app, set, nil)
120 -
121 - command := &cli.Command{
122 - Name: "test-cmd",
123 - Aliases: []string{"tc"},
124 - Usage: "this is for testing",
125 - Description: "testing",
126 - Action: func(c *cli.Context) {
127 - val := c.Int("test")
128 - expect(t, val, 15)
129 - },
130 - Flags: []cli.Flag{
131 - NewIntFlag(cli.IntFlag{Name: "test", Value: 7}),
132 - cli.StringFlag{Name: "load"}},
133 - }
134 - command.Before = InitInputSourceWithContext(command.Flags, NewYamlSourceFromFlagFunc("load"))
135 -
136 - err := command.Run(c)
137 -
138 - expect(t, err, nil)
139 -}
140 -
141 -func TestCommandYamlFileFlagHasDefaultGlobalEnvYamlSetGlobalEnvWins(t *testing.T) {
142 - app := cli.NewApp()
143 - set := flag.NewFlagSet("test", 0)
144 - ioutil.WriteFile("current.yaml", []byte("test: 15"), 0666)
145 - defer os.Remove("current.yaml")
146 -
147 - os.Setenv("THE_TEST", "11")
148 - defer os.Setenv("THE_TEST", "")
149 -
150 - test := []string{"test-cmd", "--load", "current.yaml"}
151 - set.Parse(test)
152 -
153 - c := cli.NewContext(app, set, nil)
154 -
155 - command := &cli.Command{
156 - Name: "test-cmd",
157 - Aliases: []string{"tc"},
158 - Usage: "this is for testing",
159 - Description: "testing",
160 - Action: func(c *cli.Context) {
161 - val := c.Int("test")
162 - expect(t, val, 11)
163 - },
164 - Flags: []cli.Flag{
165 - NewIntFlag(cli.IntFlag{Name: "test", Value: 7, EnvVar: "THE_TEST"}),
166 - cli.StringFlag{Name: "load"}},
167 - }
168 - command.Before = InitInputSourceWithContext(command.Flags, NewYamlSourceFromFlagFunc("load"))
169 - err := command.Run(c)
170 -
171 - expect(t, err, nil)
172 -}
Godeps/_workspace/src/github.com/codegangsta/cli/altsrc/yaml_file_loader.go deleted
-84
@@ -1,84 +0,0 @@
1 -// Disabling building of yaml support in cases where golang is 1.0 or 1.1
2 -// as the encoding library is not implemented or supported.
3 -
4 -// +build !go1,!go1.1
5 -
6 -package altsrc
7 -
8 -import (
9 - "fmt"
10 - "io/ioutil"
11 - "net/http"
12 - "net/url"
13 - "os"
14 -
15 - "github.com/codegangsta/cli"
16 -
17 - "gopkg.in/yaml.v2"
18 -)
19 -
20 -type yamlSourceContext struct {
21 - FilePath string
22 -}
23 -
24 -// NewYamlSourceFromFile creates a new Yaml InputSourceContext from a filepath.
25 -func NewYamlSourceFromFile(file string) (InputSourceContext, error) {
26 - ymlLoader := &yamlSourceLoader{FilePath: file}
27 - var results map[string]interface{}
28 - err := readCommandYaml(ysl.FilePath, &results)
29 - if err != nil {
30 - return fmt.Errorf("Unable to load Yaml file '%s': inner error: \n'%v'", filePath, err.Error())
31 - }
32 -
33 - return &MapInputSource{valueMap: results}, nil
34 -}
35 -
36 -// NewYamlSourceFromFlagFunc creates a new Yaml InputSourceContext from a provided flag name and source context.
37 -func NewYamlSourceFromFlagFunc(flagFileName string) func(InputSourceContext, error) {
38 - return func(context cli.Context) {
39 - filePath := context.String(flagFileName)
40 - return NewYamlSourceFromFile(filePath)
41 - }
42 -}
43 -
44 -func readCommandYaml(filePath string, container interface{}) (err error) {
45 - b, err := loadDataFrom(filePath)
46 - if err != nil {
47 - return err
48 - }
49 -
50 - err = yaml.Unmarshal(b, container)
51 - if err != nil {
52 - return err
53 - }
54 -
55 - err = nil
56 - return
57 -}
58 -
59 -func loadDataFrom(filePath string) ([]byte, error) {
60 - u, err := url.Parse(filePath)
61 - if err != nil {
62 - return nil, err
63 - }
64 -
65 - if u.Host != "" { // i have a host, now do i support the scheme?
66 - switch u.Scheme {
67 - case "http", "https":
68 - res, err := http.Get(filePath)
69 - if err != nil {
70 - return nil, err
71 - }
72 - return ioutil.ReadAll(res.Body)
73 - default:
74 - return nil, fmt.Errorf("scheme of %s is unsupported", filePath)
75 - }
76 - } else if u.Path != "" { // i dont have a host, but I have a path. I am a local file.
77 - if _, notFoundFileErr := os.Stat(filePath); notFoundFileErr != nil {
78 - return nil, fmt.Errorf("Cannot read from file: '%s' because it does not exist.", filePath)
79 - }
80 - return ioutil.ReadFile(filePath)
81 - } else {
82 - return nil, fmt.Errorf("unable to determine how to load from path %s", filePath)
83 - }
84 -}
Godeps/_workspace/src/github.com/codegangsta/cli/app.go deleted
-349
@@ -1,349 +0,0 @@
1 -package cli
2 -
3 -import (
4 - "fmt"
5 - "io"
6 - "io/ioutil"
7 - "os"
8 - "path"
9 - "time"
10 -)
11 -
12 -// App is the main structure of a cli application. It is recommended that
13 -// an app be created with the cli.NewApp() function
14 -type App struct {
15 - // The name of the program. Defaults to path.Base(os.Args[0])
16 - Name string
17 - // Full name of command for help, defaults to Name
18 - HelpName string
19 - // Description of the program.
20 - Usage string
21 - // Text to override the USAGE section of help
22 - UsageText string
23 - // Description of the program argument format.
24 - ArgsUsage string
25 - // Version of the program
26 - Version string
27 - // List of commands to execute
28 - Commands []Command
29 - // List of flags to parse
30 - Flags []Flag
31 - // Boolean to enable bash completion commands
32 - EnableBashCompletion bool
33 - // Boolean to hide built-in help command
34 - HideHelp bool
35 - // Boolean to hide built-in version flag
36 - HideVersion bool
37 - // An action to execute when the bash-completion flag is set
38 - BashComplete func(context *Context)
39 - // An action to execute before any subcommands are run, but after the context is ready
40 - // If a non-nil error is returned, no subcommands are run
41 - Before func(context *Context) error
42 - // An action to execute after any subcommands are run, but after the subcommand has finished
43 - // It is run even if Action() panics
44 - After func(context *Context) error
45 - // The action to execute when no subcommands are specified
46 - Action func(context *Context)
47 - // Execute this function if the proper command cannot be found
48 - CommandNotFound func(context *Context, command string)
49 - // Execute this function, if an usage error occurs. This is useful for displaying customized usage error messages.
50 - // This function is able to replace the original error messages.
51 - // If this function is not set, the "Incorrect usage" is displayed and the execution is interrupted.
52 - OnUsageError func(context *Context, err error, isSubcommand bool) error
53 - // Compilation date
54 - Compiled time.Time
55 - // List of all authors who contributed
56 - Authors []Author
57 - // Copyright of the binary if any
58 - Copyright string
59 - // Name of Author (NOTE: Use App.Authors, this is deprecated)
60 - Author string
61 - // Email of Author (NOTE: Use App.Authors, this is deprecated)
62 - Email string
63 - // Writer writer to write output to
64 - Writer io.Writer
65 -}
66 -
67 -// Tries to find out when this binary was compiled.
68 -// Returns the current time if it fails to find it.
69 -func compileTime() time.Time {
70 - info, err := os.Stat(os.Args[0])
71 - if err != nil {
72 - return time.Now()
73 - }
74 - return info.ModTime()
75 -}
76 -
77 -// Creates a new cli Application with some reasonable defaults for Name, Usage, Version and Action.
78 -func NewApp() *App {
79 - return &App{
80 - Name: path.Base(os.Args[0]),
81 - HelpName: path.Base(os.Args[0]),
82 - Usage: "A new cli application",
83 - UsageText: "",
84 - Version: "0.0.0",
85 - BashComplete: DefaultAppComplete,
86 - Action: helpCommand.Action,
87 - Compiled: compileTime(),
88 - Writer: os.Stdout,
89 - }
90 -}
91 -
92 -// Entry point to the cli app. Parses the arguments slice and routes to the proper flag/args combination
93 -func (a *App) Run(arguments []string) (err error) {
94 - if a.Author != "" || a.Email != "" {
95 - a.Authors = append(a.Authors, Author{Name: a.Author, Email: a.Email})
96 - }
97 -
98 - newCmds := []Command{}
99 - for _, c := range a.Commands {
100 - if c.HelpName == "" {
101 - c.HelpName = fmt.Sprintf("%s %s", a.HelpName, c.Name)
102 - }
103 - newCmds = append(newCmds, c)
104 - }
105 - a.Commands = newCmds
106 -
107 - // append help to commands
108 - if a.Command(helpCommand.Name) == nil && !a.HideHelp {
109 - a.Commands = append(a.Commands, helpCommand)
110 - if (HelpFlag != BoolFlag{}) {
111 - a.appendFlag(HelpFlag)
112 - }
113 - }
114 -
115 - //append version/help flags
116 - if a.EnableBashCompletion {
117 - a.appendFlag(BashCompletionFlag)
118 - }
119 -
120 - if !a.HideVersion {
121 - a.appendFlag(VersionFlag)
122 - }
123 -
124 - // parse flags
125 - set := flagSet(a.Name, a.Flags)
126 - set.SetOutput(ioutil.Discard)
127 - err = set.Parse(arguments[1:])
128 - nerr := normalizeFlags(a.Flags, set)
129 - context := NewContext(a, set, nil)
130 - if nerr != nil {
131 - fmt.Fprintln(a.Writer, nerr)
132 - ShowAppHelp(context)
133 - return nerr
134 - }
135 -
136 - if checkCompletions(context) {
137 - return nil
138 - }
139 -
140 - if err != nil {
141 - if a.OnUsageError != nil {
142 - err := a.OnUsageError(context, err, false)
143 - return err
144 - } else {
145 - fmt.Fprintf(a.Writer, "%s\n\n", "Incorrect Usage.")
146 - ShowAppHelp(context)
147 - return err
148 - }
149 - }
150 -
151 - if !a.HideHelp && checkHelp(context) {
152 - ShowAppHelp(context)
153 - return nil
154 - }
155 -
156 - if !a.HideVersion && checkVersion(context) {
157 - ShowVersion(context)
158 - return nil
159 - }
160 -
161 - if a.After != nil {
162 - defer func() {
163 - if afterErr := a.After(context); afterErr != nil {
164 - if err != nil {
165 - err = NewMultiError(err, afterErr)
166 - } else {
167 - err = afterErr
168 - }
169 - }
170 - }()
171 - }
172 -
173 - if a.Before != nil {
174 - err = a.Before(context)
175 - if err != nil {
176 - fmt.Fprintf(a.Writer, "%v\n\n", err)
177 - ShowAppHelp(context)
178 - return err
179 - }
180 - }
181 -
182 - args := context.Args()
183 - if args.Present() {
184 - name := args.First()
185 - c := a.Command(name)
186 - if c != nil {
187 - return c.Run(context)
188 - }
189 - }
190 -
191 - // Run default Action
192 - a.Action(context)
193 - return nil
194 -}
195 -
196 -// Another entry point to the cli app, takes care of passing arguments and error handling
197 -func (a *App) RunAndExitOnError() {
198 - if err := a.Run(os.Args); err != nil {
199 - fmt.Fprintln(os.Stderr, err)
200 - os.Exit(1)
201 - }
202 -}
203 -
204 -// Invokes the subcommand given the context, parses ctx.Args() to generate command-specific flags
205 -func (a *App) RunAsSubcommand(ctx *Context) (err error) {
206 - // append help to commands
207 - if len(a.Commands) > 0 {
208 - if a.Command(helpCommand.Name) == nil && !a.HideHelp {
209 - a.Commands = append(a.Commands, helpCommand)
210 - if (HelpFlag != BoolFlag{}) {
211 - a.appendFlag(HelpFlag)
212 - }
213 - }
214 - }
215 -
216 - newCmds := []Command{}
217 - for _, c := range a.Commands {
218 - if c.HelpName == "" {
219 - c.HelpName = fmt.Sprintf("%s %s", a.HelpName, c.Name)
220 - }
221 - newCmds = append(newCmds, c)
222 - }
223 - a.Commands = newCmds
224 -
225 - // append flags
226 - if a.EnableBashCompletion {
227 - a.appendFlag(BashCompletionFlag)
228 - }
229 -
230 - // parse flags
231 - set := flagSet(a.Name, a.Flags)
232 - set.SetOutput(ioutil.Discard)
233 - err = set.Parse(ctx.Args().Tail())
234 - nerr := normalizeFlags(a.Flags, set)
235 - context := NewContext(a, set, ctx)
236 -
237 - if nerr != nil {
238 - fmt.Fprintln(a.Writer, nerr)
239 - fmt.Fprintln(a.Writer)
240 - if len(a.Commands) > 0 {
241 - ShowSubcommandHelp(context)
242 - } else {
243 - ShowCommandHelp(ctx, context.Args().First())
244 - }
245 - return nerr
246 - }
247 -
248 - if checkCompletions(context) {
249 - return nil
250 - }
251 -
252 - if err != nil {
253 - if a.OnUsageError != nil {
254 - err = a.OnUsageError(context, err, true)
255 - return err
256 - } else {
257 - fmt.Fprintf(a.Writer, "%s\n\n", "Incorrect Usage.")
258 - ShowSubcommandHelp(context)
259 - return err
260 - }
261 - }
262 -
263 - if len(a.Commands) > 0 {
264 - if checkSubcommandHelp(context) {
265 - return nil
266 - }
267 - } else {
268 - if checkCommandHelp(ctx, context.Args().First()) {
269 - return nil
270 - }
271 - }
272 -
273 - if a.After != nil {
274 - defer func() {
275 - afterErr := a.After(context)
276 - if afterErr != nil {
277 - if err != nil {
278 - err = NewMultiError(err, afterErr)
279 - } else {
280 - err = afterErr
281 - }
282 - }
283 - }()
284 - }
285 -
286 - if a.Before != nil {
287 - err := a.Before(context)
288 - if err != nil {
289 - return err
290 - }
291 - }
292 -
293 - args := context.Args()
294 - if args.Present() {
295 - name := args.First()
296 - c := a.Command(name)
297 - if c != nil {
298 - return c.Run(context)
299 - }
300 - }
301 -
302 - // Run default Action
303 - a.Action(context)
304 -
305 - return nil
306 -}
307 -
308 -// Returns the named command on App. Returns nil if the command does not exist
309 -func (a *App) Command(name string) *Command {
310 - for _, c := range a.Commands {
311 - if c.HasName(name) {
312 - return &c
313 - }
314 - }
315 -
316 - return nil
317 -}
318 -
319 -func (a *App) hasFlag(flag Flag) bool {
320 - for _, f := range a.Flags {
321 - if flag == f {
322 - return true
323 - }
324 - }
325 -
326 - return false
327 -}
328 -
329 -func (a *App) appendFlag(flag Flag) {
330 - if !a.hasFlag(flag) {
331 - a.Flags = append(a.Flags, flag)
332 - }
333 -}
334 -
335 -// Author represents someone who has contributed to a cli project.
336 -type Author struct {
337 - Name string // The Authors name
338 - Email string // The Authors email
339 -}
340 -
341 -// String makes Author comply to the Stringer interface, to allow an easy print in the templating process
342 -func (a Author) String() string {
343 - e := ""
344 - if a.Email != "" {
345 - e = "<" + a.Email + "> "
346 - }
347 -
348 - return fmt.Sprintf("%v %v", a.Name, e)
349 -}
Godeps/_workspace/src/github.com/codegangsta/cli/app_test.go deleted
-1047
@@ -1,1047 +0,0 @@
1 -package cli
2 -
3 -import (
4 - "bytes"
5 - "errors"
6 - "flag"
7 - "fmt"
8 - "io"
9 - "io/ioutil"
10 - "os"
11 - "strings"
12 - "testing"
13 -)
14 -
15 -func ExampleApp_Run() {
16 - // set args for examples sake
17 - os.Args = []string{"greet", "--name", "Jeremy"}
18 -
19 - app := NewApp()
20 - app.Name = "greet"
21 - app.Flags = []Flag{
22 - StringFlag{Name: "name", Value: "bob", Usage: "a name to say"},
23 - }
24 - app.Action = func(c *Context) {
25 - fmt.Printf("Hello %v\n", c.String("name"))
26 - }
27 - app.UsageText = "app [first_arg] [second_arg]"
28 - app.Author = "Harrison"
29 - app.Email = "harrison@lolwut.com"
30 - app.Authors = []Author{Author{Name: "Oliver Allen", Email: "oliver@toyshop.com"}}
31 - app.Run(os.Args)
32 - // Output:
33 - // Hello Jeremy
34 -}
35 -
36 -func ExampleApp_Run_subcommand() {
37 - // set args for examples sake
38 - os.Args = []string{"say", "hi", "english", "--name", "Jeremy"}
39 - app := NewApp()
40 - app.Name = "say"
41 - app.Commands = []Command{
42 - {
43 - Name: "hello",
44 - Aliases: []string{"hi"},
45 - Usage: "use it to see a description",
46 - Description: "This is how we describe hello the function",
47 - Subcommands: []Command{
48 - {
49 - Name: "english",
50 - Aliases: []string{"en"},
51 - Usage: "sends a greeting in english",
52 - Description: "greets someone in english",
53 - Flags: []Flag{
54 - StringFlag{
55 - Name: "name",
56 - Value: "Bob",
57 - Usage: "Name of the person to greet",
58 - },
59 - },
60 - Action: func(c *Context) {
61 - fmt.Println("Hello,", c.String("name"))
62 - },
63 - },
64 - },
65 - },
66 - }
67 -
68 - app.Run(os.Args)
69 - // Output:
70 - // Hello, Jeremy
71 -}
72 -
73 -func ExampleApp_Run_help() {
74 - // set args for examples sake
75 - os.Args = []string{"greet", "h", "describeit"}
76 -
77 - app := NewApp()
78 - app.Name = "greet"
79 - app.Flags = []Flag{
80 - StringFlag{Name: "name", Value: "bob", Usage: "a name to say"},
81 - }
82 - app.Commands = []Command{
83 - {
84 - Name: "describeit",
85 - Aliases: []string{"d"},
86 - Usage: "use it to see a description",
87 - Description: "This is how we describe describeit the function",
88 - Action: func(c *Context) {
89 - fmt.Printf("i like to describe things")
90 - },
91 - },
92 - }
93 - app.Run(os.Args)
94 - // Output:
95 - // NAME:
96 - // greet describeit - use it to see a description
97 - //
98 - // USAGE:
99 - // greet describeit [arguments...]
100 - //
101 - // DESCRIPTION:
102 - // This is how we describe describeit the function
103 -}
104 -
105 -func ExampleApp_Run_bashComplete() {
106 - // set args for examples sake
107 - os.Args = []string{"greet", "--generate-bash-completion"}
108 -
109 - app := NewApp()
110 - app.Name = "greet"
111 - app.EnableBashCompletion = true
112 - app.Commands = []Command{
113 - {
114 - Name: "describeit",
115 - Aliases: []string{"d"},
116 - Usage: "use it to see a description",
117 - Description: "This is how we describe describeit the function",
118 - Action: func(c *Context) {
119 - fmt.Printf("i like to describe things")
120 - },
121 - }, {
122 - Name: "next",
123 - Usage: "next example",
124 - Description: "more stuff to see when generating bash completion",
125 - Action: func(c *Context) {
126 - fmt.Printf("the next example")
127 - },
128 - },
129 - }
130 -
131 - app.Run(os.Args)
132 - // Output:
133 - // describeit
134 - // d
135 - // next
136 - // help
137 - // h
138 -}
139 -
140 -func TestApp_Run(t *testing.T) {
141 - s := ""
142 -
143 - app := NewApp()
144 - app.Action = func(c *Context) {
145 - s = s + c.Args().First()
146 - }
147 -
148 - err := app.Run([]string{"command", "foo"})
149 - expect(t, err, nil)
150 - err = app.Run([]string{"command", "bar"})
151 - expect(t, err, nil)
152 - expect(t, s, "foobar")
153 -}
154 -
155 -var commandAppTests = []struct {
156 - name string
157 - expected bool
158 -}{
159 - {"foobar", true},
160 - {"batbaz", true},
161 - {"b", true},
162 - {"f", true},
163 - {"bat", false},
164 - {"nothing", false},
165 -}
166 -
167 -func TestApp_Command(t *testing.T) {
168 - app := NewApp()
169 - fooCommand := Command{Name: "foobar", Aliases: []string{"f"}}
170 - batCommand := Command{Name: "batbaz", Aliases: []string{"b"}}
171 - app.Commands = []Command{
172 - fooCommand,
173 - batCommand,
174 - }
175 -
176 - for _, test := range commandAppTests {
177 - expect(t, app.Command(test.name) != nil, test.expected)
178 - }
179 -}
180 -
181 -func TestApp_CommandWithArgBeforeFlags(t *testing.T) {
182 - var parsedOption, firstArg string
183 -
184 - app := NewApp()
185 - command := Command{
186 - Name: "cmd",
187 - Flags: []Flag{
188 - StringFlag{Name: "option", Value: "", Usage: "some option"},
189 - },
190 - Action: func(c *Context) {
191 - parsedOption = c.String("option")
192 - firstArg = c.Args().First()
193 - },
194 - }
195 - app.Commands = []Command{command}
196 -
197 - app.Run([]string{"", "cmd", "my-arg", "--option", "my-option"})
198 -
199 - expect(t, parsedOption, "my-option")
200 - expect(t, firstArg, "my-arg")
201 -}
202 -
203 -func TestApp_RunAsSubcommandParseFlags(t *testing.T) {
204 - var context *Context
205 -
206 - a := NewApp()
207 - a.Commands = []Command{
208 - {
209 - Name: "foo",
210 - Action: func(c *Context) {
211 - context = c
212 - },
213 - Flags: []Flag{
214 - StringFlag{
215 - Name: "lang",
216 - Value: "english",
217 - Usage: "language for the greeting",
218 - },
219 - },
220 - Before: func(_ *Context) error { return nil },
221 - },
222 - }
223 - a.Run([]string{"", "foo", "--lang", "spanish", "abcd"})
224 -
225 - expect(t, context.Args().Get(0), "abcd")
226 - expect(t, context.String("lang"), "spanish")
227 -}
228 -
229 -func TestApp_CommandWithFlagBeforeTerminator(t *testing.T) {
230 - var parsedOption string
231 - var args []string
232 -
233 - app := NewApp()
234 - command := Command{
235 - Name: "cmd",
236 - Flags: []Flag{
237 - StringFlag{Name: "option", Value: "", Usage: "some option"},
238 - },
239 - Action: func(c *Context) {
240 - parsedOption = c.String("option")
241 - args = c.Args()
242 - },
243 - }
244 - app.Commands = []Command{command}
245 -
246 - app.Run([]string{"", "cmd", "my-arg", "--option", "my-option", "--", "--notARealFlag"})
247 -
248 - expect(t, parsedOption, "my-option")
249 - expect(t, args[0], "my-arg")
250 - expect(t, args[1], "--")
251 - expect(t, args[2], "--notARealFlag")
252 -}
253 -
254 -func TestApp_CommandWithDash(t *testing.T) {
255 - var args []string
256 -
257 - app := NewApp()
258 - command := Command{
259 - Name: "cmd",
260 - Action: func(c *Context) {
261 - args = c.Args()
262 - },
263 - }
264 - app.Commands = []Command{command}
265 -
266 - app.Run([]string{"", "cmd", "my-arg", "-"})
267 -
268 - expect(t, args[0], "my-arg")
269 - expect(t, args[1], "-")
270 -}
271 -
272 -func TestApp_CommandWithNoFlagBeforeTerminator(t *testing.T) {
273 - var args []string
274 -
275 - app := NewApp()
276 - command := Command{
277 - Name: "cmd",
278 - Action: func(c *Context) {
279 - args = c.Args()
280 - },
281 - }
282 - app.Commands = []Command{command}
283 -
284 - app.Run([]string{"", "cmd", "my-arg", "--", "notAFlagAtAll"})
285 -
286 - expect(t, args[0], "my-arg")
287 - expect(t, args[1], "--")
288 - expect(t, args[2], "notAFlagAtAll")
289 -}
290 -
291 -func TestApp_Float64Flag(t *testing.T) {
292 - var meters float64
293 -
294 - app := NewApp()
295 - app.Flags = []Flag{
296 - Float64Flag{Name: "height", Value: 1.5, Usage: "Set the height, in meters"},
297 - }
298 - app.Action = func(c *Context) {
299 - meters = c.Float64("height")
300 - }
301 -
302 - app.Run([]string{"", "--height", "1.93"})
303 - expect(t, meters, 1.93)
304 -}
305 -
306 -func TestApp_ParseSliceFlags(t *testing.T) {
307 - var parsedOption, firstArg string
308 - var parsedIntSlice []int
309 - var parsedStringSlice []string
310 -
311 - app := NewApp()
312 - command := Command{
313 - Name: "cmd",
314 - Flags: []Flag{
315 - IntSliceFlag{Name: "p", Value: &IntSlice{}, Usage: "set one or more ip addr"},
316 - StringSliceFlag{Name: "ip", Value: &StringSlice{}, Usage: "set one or more ports to open"},
317 - },
318 - Action: func(c *Context) {
319 - parsedIntSlice = c.IntSlice("p")
320 - parsedStringSlice = c.StringSlice("ip")
321 - parsedOption = c.String("option")
322 - firstArg = c.Args().First()
323 - },
324 - }
325 - app.Commands = []Command{command}
326 -
327 - app.Run([]string{"", "cmd", "my-arg", "-p", "22", "-p", "80", "-ip", "8.8.8.8", "-ip", "8.8.4.4"})
328 -
329 - IntsEquals := func(a, b []int) bool {
330 - if len(a) != len(b) {
331 - return false
332 - }
333 - for i, v := range a {
334 - if v != b[i] {
335 - return false
336 - }
337 - }
338 - return true
339 - }
340 -
341 - StrsEquals := func(a, b []string) bool {
342 - if len(a) != len(b) {
343 - return false
344 - }
345 - for i, v := range a {
346 - if v != b[i] {
347 - return false
348 - }
349 - }
350 - return true
351 - }
352 - var expectedIntSlice = []int{22, 80}
353 - var expectedStringSlice = []string{"8.8.8.8", "8.8.4.4"}
354 -
355 - if !IntsEquals(parsedIntSlice, expectedIntSlice) {
356 - t.Errorf("%v does not match %v", parsedIntSlice, expectedIntSlice)
357 - }
358 -
359 - if !StrsEquals(parsedStringSlice, expectedStringSlice) {
360 - t.Errorf("%v does not match %v", parsedStringSlice, expectedStringSlice)
361 - }
362 -}
363 -
364 -func TestApp_ParseSliceFlagsWithMissingValue(t *testing.T) {
365 - var parsedIntSlice []int
366 - var parsedStringSlice []string
367 -
368 - app := NewApp()
369 - command := Command{
370 - Name: "cmd",
371 - Flags: []Flag{
372 - IntSliceFlag{Name: "a", Usage: "set numbers"},
373 - StringSliceFlag{Name: "str", Usage: "set strings"},
374 - },
375 - Action: func(c *Context) {
376 - parsedIntSlice = c.IntSlice("a")
377 - parsedStringSlice = c.StringSlice("str")
378 - },
379 - }
380 - app.Commands = []Command{command}
381 -
382 - app.Run([]string{"", "cmd", "my-arg", "-a", "2", "-str", "A"})
383 -
384 - var expectedIntSlice = []int{2}
385 - var expectedStringSlice = []string{"A"}
386 -
387 - if parsedIntSlice[0] != expectedIntSlice[0] {
388 - t.Errorf("%v does not match %v", parsedIntSlice[0], expectedIntSlice[0])
389 - }
390 -
391 - if parsedStringSlice[0] != expectedStringSlice[0] {
392 - t.Errorf("%v does not match %v", parsedIntSlice[0], expectedIntSlice[0])
393 - }
394 -}
395 -
396 -func TestApp_DefaultStdout(t *testing.T) {
397 - app := NewApp()
398 -
399 - if app.Writer != os.Stdout {
400 - t.Error("Default output writer not set.")
401 - }
402 -}
403 -
404 -type mockWriter struct {
405 - written []byte
406 -}
407 -
408 -func (fw *mockWriter) Write(p []byte) (n int, err error) {
409 - if fw.written == nil {
410 - fw.written = p
411 - } else {
412 - fw.written = append(fw.written, p...)
413 - }
414 -
415 - return len(p), nil
416 -}
417 -
418 -func (fw *mockWriter) GetWritten() (b []byte) {
419 - return fw.written
420 -}
421 -
422 -func TestApp_SetStdout(t *testing.T) {
423 - w := &mockWriter{}
424 -
425 - app := NewApp()
426 - app.Name = "test"
427 - app.Writer = w
428 -
429 - err := app.Run([]string{"help"})
430 -
431 - if err != nil {
432 - t.Fatalf("Run error: %s", err)
433 - }
434 -
435 - if len(w.written) == 0 {
436 - t.Error("App did not write output to desired writer.")
437 - }
438 -}
439 -
440 -func TestApp_BeforeFunc(t *testing.T) {
441 - beforeRun, subcommandRun := false, false
442 - beforeError := fmt.Errorf("fail")
443 - var err error
444 -
445 - app := NewApp()
446 -
447 - app.Before = func(c *Context) error {
448 - beforeRun = true
449 - s := c.String("opt")
450 - if s == "fail" {
451 - return beforeError
452 - }
453 -
454 - return nil
455 - }
456 -
457 - app.Commands = []Command{
458 - Command{
459 - Name: "sub",
460 - Action: func(c *Context) {
461 - subcommandRun = true
462 - },
463 - },
464 - }
465 -
466 - app.Flags = []Flag{
467 - StringFlag{Name: "opt"},
468 - }
469 -
470 - // run with the Before() func succeeding
471 - err = app.Run([]string{"command", "--opt", "succeed", "sub"})
472 -
473 - if err != nil {
474 - t.Fatalf("Run error: %s", err)
475 - }
476 -
477 - if beforeRun == false {
478 - t.Errorf("Before() not executed when expected")
479 - }
480 -
481 - if subcommandRun == false {
482 - t.Errorf("Subcommand not executed when expected")
483 - }
484 -
485 - // reset
486 - beforeRun, subcommandRun = false, false
487 -
488 - // run with the Before() func failing
489 - err = app.Run([]string{"command", "--opt", "fail", "sub"})
490 -
491 - // should be the same error produced by the Before func
492 - if err != beforeError {
493 - t.Errorf("Run error expected, but not received")
494 - }
495 -
496 - if beforeRun == false {
497 - t.Errorf("Before() not executed when expected")
498 - }
499 -
500 - if subcommandRun == true {
501 - t.Errorf("Subcommand executed when NOT expected")
502 - }
503 -
504 -}
505 -
506 -func TestApp_AfterFunc(t *testing.T) {
507 - afterRun, subcommandRun := false, false
508 - afterError := fmt.Errorf("fail")
509 - var err error
510 -
511 - app := NewApp()
512 -
513 - app.After = func(c *Context) error {
514 - afterRun = true
515 - s := c.String("opt")
516 - if s == "fail" {
517 - return afterError
518 - }
519 -
520 - return nil
521 - }
522 -
523 - app.Commands = []Command{
524 - Command{
525 - Name: "sub",
526 - Action: func(c *Context) {
527 - subcommandRun = true
528 - },
529 - },
530 - }
531 -
532 - app.Flags = []Flag{
533 - StringFlag{Name: "opt"},
534 - }
535 -
536 - // run with the After() func succeeding
537 - err = app.Run([]string{"command", "--opt", "succeed", "sub"})
538 -
539 - if err != nil {
540 - t.Fatalf("Run error: %s", err)
541 - }
542 -
543 - if afterRun == false {
544 - t.Errorf("After() not executed when expected")
545 - }
546 -
547 - if subcommandRun == false {
548 - t.Errorf("Subcommand not executed when expected")
549 - }
550 -
551 - // reset
552 - afterRun, subcommandRun = false, false
553 -
554 - // run with the Before() func failing
555 - err = app.Run([]string{"command", "--opt", "fail", "sub"})
556 -
557 - // should be the same error produced by the Before func
558 - if err != afterError {
559 - t.Errorf("Run error expected, but not received")
560 - }
561 -
562 - if afterRun == false {
563 - t.Errorf("After() not executed when expected")
564 - }
565 -
566 - if subcommandRun == false {
567 - t.Errorf("Subcommand not executed when expected")
568 - }
569 -}
570 -
571 -func TestAppNoHelpFlag(t *testing.T) {
572 - oldFlag := HelpFlag
573 - defer func() {
574 - HelpFlag = oldFlag
575 - }()
576 -
577 - HelpFlag = BoolFlag{}
578 -
579 - app := NewApp()
580 - app.Writer = ioutil.Discard
581 - err := app.Run([]string{"test", "-h"})
582 -
583 - if err != flag.ErrHelp {
584 - t.Errorf("expected error about missing help flag, but got: %s (%T)", err, err)
585 - }
586 -}
587 -
588 -func TestAppHelpPrinter(t *testing.T) {
589 - oldPrinter := HelpPrinter
590 - defer func() {
591 - HelpPrinter = oldPrinter
592 - }()
593 -
594 - var wasCalled = false
595 - HelpPrinter = func(w io.Writer, template string, data interface{}) {
596 - wasCalled = true
597 - }
598 -
599 - app := NewApp()
600 - app.Run([]string{"-h"})
601 -
602 - if wasCalled == false {
603 - t.Errorf("Help printer expected to be called, but was not")
604 - }
605 -}
606 -
607 -func TestAppVersionPrinter(t *testing.T) {
608 - oldPrinter := VersionPrinter
609 - defer func() {
610 - VersionPrinter = oldPrinter
611 - }()
612 -
613 - var wasCalled = false
614 - VersionPrinter = func(c *Context) {
615 - wasCalled = true
616 - }
617 -
618 - app := NewApp()
619 - ctx := NewContext(app, nil, nil)
620 - ShowVersion(ctx)
621 -
622 - if wasCalled == false {
623 - t.Errorf("Version printer expected to be called, but was not")
624 - }
625 -}
626 -
627 -func TestAppCommandNotFound(t *testing.T) {
628 - beforeRun, subcommandRun := false, false
629 - app := NewApp()
630 -
631 - app.CommandNotFound = func(c *Context, command string) {
632 - beforeRun = true
633 - }
634 -
635 - app.Commands = []Command{
636 - Command{
637 - Name: "bar",
638 - Action: func(c *Context) {
639 - subcommandRun = true
640 - },
641 - },
642 - }
643 -
644 - app.Run([]string{"command", "foo"})
645 -
646 - expect(t, beforeRun, true)
647 - expect(t, subcommandRun, false)
648 -}
649 -
650 -func TestGlobalFlag(t *testing.T) {
651 - var globalFlag string
652 - var globalFlagSet bool
653 - app := NewApp()
654 - app.Flags = []Flag{
655 - StringFlag{Name: "global, g", Usage: "global"},
656 - }
657 - app.Action = func(c *Context) {
658 - globalFlag = c.GlobalString("global")
659 - globalFlagSet = c.GlobalIsSet("global")
660 - }
661 - app.Run([]string{"command", "-g", "foo"})
662 - expect(t, globalFlag, "foo")
663 - expect(t, globalFlagSet, true)
664 -
665 -}
666 -
667 -func TestGlobalFlagsInSubcommands(t *testing.T) {
668 - subcommandRun := false
669 - parentFlag := false
670 - app := NewApp()
671 -
672 - app.Flags = []Flag{
673 - BoolFlag{Name: "debug, d", Usage: "Enable debugging"},
674 - }
675 -
676 - app.Commands = []Command{
677 - Command{
678 - Name: "foo",
679 - Flags: []Flag{
680 - BoolFlag{Name: "parent, p", Usage: "Parent flag"},
681 - },
682 - Subcommands: []Command{
683 - {
684 - Name: "bar",
685 - Action: func(c *Context) {
686 - if c.GlobalBool("debug") {
687 - subcommandRun = true
688 - }
689 - if c.GlobalBool("parent") {
690 - parentFlag = true
691 - }
692 - },
693 - },
694 - },
695 - },
696 - }
697 -
698 - app.Run([]string{"command", "-d", "foo", "-p", "bar"})
699 -
700 - expect(t, subcommandRun, true)
701 - expect(t, parentFlag, true)
702 -}
703 -
704 -func TestApp_Run_CommandWithSubcommandHasHelpTopic(t *testing.T) {
705 - var subcommandHelpTopics = [][]string{
706 - {"command", "foo", "--help"},
707 - {"command", "foo", "-h"},
708 - {"command", "foo", "help"},
709 - }
710 -
711 - for _, flagSet := range subcommandHelpTopics {
712 - t.Logf("==> checking with flags %v", flagSet)
713 -
714 - app := NewApp()
715 - buf := new(bytes.Buffer)
716 - app.Writer = buf
717 -
718 - subCmdBar := Command{
719 - Name: "bar",
720 - Usage: "does bar things",
721 - }
722 - subCmdBaz := Command{
723 - Name: "baz",
724 - Usage: "does baz things",
725 - }
726 - cmd := Command{
727 - Name: "foo",
728 - Description: "descriptive wall of text about how it does foo things",
729 - Subcommands: []Command{subCmdBar, subCmdBaz},
730 - }
731 -
732 - app.Commands = []Command{cmd}
733 - err := app.Run(flagSet)
734 -
735 - if err != nil {
736 - t.Error(err)
737 - }
738 -
739 - output := buf.String()
740 - t.Logf("output: %q\n", buf.Bytes())
741 -
742 - if strings.Contains(output, "No help topic for") {
743 - t.Errorf("expect a help topic, got none: \n%q", output)
744 - }
745 -
746 - for _, shouldContain := range []string{
747 - cmd.Name, cmd.Description,
748 - subCmdBar.Name, subCmdBar.Usage,
749 - subCmdBaz.Name, subCmdBaz.Usage,
750 - } {
751 - if !strings.Contains(output, shouldContain) {
752 - t.Errorf("want help to contain %q, did not: \n%q", shouldContain, output)
753 - }
754 - }
755 - }
756 -}
757 -
758 -func TestApp_Run_SubcommandFullPath(t *testing.T) {
759 - app := NewApp()
760 - buf := new(bytes.Buffer)
761 - app.Writer = buf
762 - app.Name = "command"
763 - subCmd := Command{
764 - Name: "bar",
765 - Usage: "does bar things",
766 - }
767 - cmd := Command{
768 - Name: "foo",
769 - Description: "foo commands",
770 - Subcommands: []Command{subCmd},
771 - }
772 - app.Commands = []Command{cmd}
773 -
774 - err := app.Run([]string{"command", "foo", "bar", "--help"})
775 - if err != nil {
776 - t.Error(err)
777 - }
778 -
779 - output := buf.String()
780 - if !strings.Contains(output, "command foo bar - does bar things") {
781 - t.Errorf("expected full path to subcommand: %s", output)
782 - }
783 - if !strings.Contains(output, "command foo bar [arguments...]") {
784 - t.Errorf("expected full path to subcommand: %s", output)
785 - }
786 -}
787 -
788 -func TestApp_Run_SubcommandHelpName(t *testing.T) {
789 - app := NewApp()
790 - buf := new(bytes.Buffer)
791 - app.Writer = buf
792 - app.Name = "command"
793 - subCmd := Command{
794 - Name: "bar",
795 - HelpName: "custom",
796 - Usage: "does bar things",
797 - }
798 - cmd := Command{
799 - Name: "foo",
800 - Description: "foo commands",
801 - Subcommands: []Command{subCmd},
802 - }
803 - app.Commands = []Command{cmd}
804 -
805 - err := app.Run([]string{"command", "foo", "bar", "--help"})
806 - if err != nil {
807 - t.Error(err)
808 - }
809 -
810 - output := buf.String()
811 - if !strings.Contains(output, "custom - does bar things") {
812 - t.Errorf("expected HelpName for subcommand: %s", output)
813 - }
814 - if !strings.Contains(output, "custom [arguments...]") {
815 - t.Errorf("expected HelpName to subcommand: %s", output)
816 - }
817 -}
818 -
819 -func TestApp_Run_CommandHelpName(t *testing.T) {
820 - app := NewApp()
821 - buf := new(bytes.Buffer)
822 - app.Writer = buf
823 - app.Name = "command"
824 - subCmd := Command{
825 - Name: "bar",
826 - Usage: "does bar things",
827 - }
828 - cmd := Command{
829 - Name: "foo",
830 - HelpName: "custom",
831 - Description: "foo commands",
832 - Subcommands: []Command{subCmd},
833 - }
834 - app.Commands = []Command{cmd}
835 -
836 - err := app.Run([]string{"command", "foo", "bar", "--help"})
837 - if err != nil {
838 - t.Error(err)
839 - }
840 -
841 - output := buf.String()
842 - if !strings.Contains(output, "command foo bar - does bar things") {
843 - t.Errorf("expected full path to subcommand: %s", output)
844 - }
845 - if !strings.Contains(output, "command foo bar [arguments...]") {
846 - t.Errorf("expected full path to subcommand: %s", output)
847 - }
848 -}
849 -
850 -func TestApp_Run_CommandSubcommandHelpName(t *testing.T) {
851 - app := NewApp()
852 - buf := new(bytes.Buffer)
853 - app.Writer = buf
854 - app.Name = "base"
855 - subCmd := Command{
856 - Name: "bar",
857 - HelpName: "custom",
858 - Usage: "does bar things",
859 - }
860 - cmd := Command{
861 - Name: "foo",
862 - Description: "foo commands",
863 - Subcommands: []Command{subCmd},
864 - }
865 - app.Commands = []Command{cmd}
866 -
867 - err := app.Run([]string{"command", "foo", "--help"})
868 - if err != nil {
869 - t.Error(err)
870 - }
871 -
872 - output := buf.String()
873 - if !strings.Contains(output, "base foo - foo commands") {
874 - t.Errorf("expected full path to subcommand: %s", output)
875 - }
876 - if !strings.Contains(output, "base foo command [command options] [arguments...]") {
877 - t.Errorf("expected full path to subcommand: %s", output)
878 - }
879 -}
880 -
881 -func TestApp_Run_Help(t *testing.T) {
882 - var helpArguments = [][]string{{"boom", "--help"}, {"boom", "-h"}, {"boom", "help"}}
883 -
884 - for _, args := range helpArguments {
885 - buf := new(bytes.Buffer)
886 -
887 - t.Logf("==> checking with arguments %v", args)
888 -
889 - app := NewApp()
890 - app.Name = "boom"
891 - app.Usage = "make an explosive entrance"
892 - app.Writer = buf
893 - app.Action = func(c *Context) {
894 - buf.WriteString("boom I say!")
895 - }
896 -
897 - err := app.Run(args)
898 - if err != nil {
899 - t.Error(err)
900 - }
901 -
902 - output := buf.String()
903 - t.Logf("output: %q\n", buf.Bytes())
904 -
905 - if !strings.Contains(output, "boom - make an explosive entrance") {
906 - t.Errorf("want help to contain %q, did not: \n%q", "boom - make an explosive entrance", output)
907 - }
908 - }
909 -}
910 -
911 -func TestApp_Run_Version(t *testing.T) {
912 - var versionArguments = [][]string{{"boom", "--version"}, {"boom", "-v"}}
913 -
914 - for _, args := range versionArguments {
915 - buf := new(bytes.Buffer)
916 -
917 - t.Logf("==> checking with arguments %v", args)
918 -
919 - app := NewApp()
920 - app.Name = "boom"
921 - app.Usage = "make an explosive entrance"
922 - app.Version = "0.1.0"
923 - app.Writer = buf
924 - app.Action = func(c *Context) {
925 - buf.WriteString("boom I say!")
926 - }
927 -
928 - err := app.Run(args)
929 - if err != nil {
930 - t.Error(err)
931 - }
932 -
933 - output := buf.String()
934 - t.Logf("output: %q\n", buf.Bytes())
935 -
936 - if !strings.Contains(output, "0.1.0") {
937 - t.Errorf("want version to contain %q, did not: \n%q", "0.1.0", output)
938 - }
939 - }
940 -}
941 -
942 -func TestApp_Run_DoesNotOverwriteErrorFromBefore(t *testing.T) {
943 - app := NewApp()
944 - app.Action = func(c *Context) {}
945 - app.Before = func(c *Context) error { return fmt.Errorf("before error") }
946 - app.After = func(c *Context) error { return fmt.Errorf("after error") }
947 -
948 - err := app.Run([]string{"foo"})
949 - if err == nil {
950 - t.Fatalf("expected to receive error from Run, got none")
951 - }
952 -
953 - if !strings.Contains(err.Error(), "before error") {
954 - t.Errorf("expected text of error from Before method, but got none in \"%v\"", err)
955 - }
956 - if !strings.Contains(err.Error(), "after error") {
957 - t.Errorf("expected text of error from After method, but got none in \"%v\"", err)
958 - }
959 -}
960 -
961 -func TestApp_Run_SubcommandDoesNotOverwriteErrorFromBefore(t *testing.T) {
962 - app := NewApp()
963 - app.Commands = []Command{
964 - Command{
965 - Subcommands: []Command{
966 - Command{
967 - Name: "sub",
968 - },
969 - },
970 - Name: "bar",
971 - Before: func(c *Context) error { return fmt.Errorf("before error") },
972 - After: func(c *Context) error { return fmt.Errorf("after error") },
973 - },
974 - }
975 -
976 - err := app.Run([]string{"foo", "bar"})
977 - if err == nil {
978 - t.Fatalf("expected to receive error from Run, got none")
979 - }
980 -
981 - if !strings.Contains(err.Error(), "before error") {
982 - t.Errorf("expected text of error from Before method, but got none in \"%v\"", err)
983 - }
984 - if !strings.Contains(err.Error(), "after error") {
985 - t.Errorf("expected text of error from After method, but got none in \"%v\"", err)
986 - }
987 -}
988 -
989 -func TestApp_OnUsageError_WithWrongFlagValue(t *testing.T) {
990 - app := NewApp()
991 - app.Flags = []Flag{
992 - IntFlag{Name: "flag"},
993 - }
994 - app.OnUsageError = func(c *Context, err error, isSubcommand bool) error {
995 - if isSubcommand {
996 - t.Errorf("Expect no subcommand")
997 - }
998 - if !strings.HasPrefix(err.Error(), "invalid value \"wrong\"") {
999 - t.Errorf("Expect an invalid value error, but got \"%v\"", err)
1000 - }
1001 - return errors.New("intercepted: " + err.Error())
1002 - }
1003 - app.Commands = []Command{
1004 - Command{
1005 - Name: "bar",
1006 - },
1007 - }
1008 -
1009 - err := app.Run([]string{"foo", "--flag=wrong"})
1010 - if err == nil {
1011 - t.Fatalf("expected to receive error from Run, got none")
1012 - }
1013 -
1014 - if !strings.HasPrefix(err.Error(), "intercepted: invalid value") {
1015 - t.Errorf("Expect an intercepted error, but got \"%v\"", err)
1016 - }
1017 -}
1018 -
1019 -func TestApp_OnUsageError_WithWrongFlagValue_ForSubcommand(t *testing.T) {
1020 - app := NewApp()
1021 - app.Flags = []Flag{
1022 - IntFlag{Name: "flag"},
1023 - }
1024 - app.OnUsageError = func(c *Context, err error, isSubcommand bool) error {
1025 - if isSubcommand {
1026 - t.Errorf("Expect subcommand")
1027 - }
1028 - if !strings.HasPrefix(err.Error(), "invalid value \"wrong\"") {
1029 - t.Errorf("Expect an invalid value error, but got \"%v\"", err)
1030 - }
1031 - return errors.New("intercepted: " + err.Error())
1032 - }
1033 - app.Commands = []Command{
1034 - Command{
1035 - Name: "bar",
1036 - },
1037 - }
1038 -
1039 - err := app.Run([]string{"foo", "--flag=wrong", "bar"})
1040 - if err == nil {
1041 - t.Fatalf("expected to receive error from Run, got none")
1042 - }
1043 -
1044 - if !strings.HasPrefix(err.Error(), "intercepted: invalid value") {
1045 - t.Errorf("Expect an intercepted error, but got \"%v\"", err)
1046 - }
1047 -}
Godeps/_workspace/src/github.com/codegangsta/cli/appveyor.yml deleted
-16
@@ -1,16 +0,0 @@
1 -version: "{build}"
2 -
3 -os: Windows Server 2012 R2
4 -
5 -install:
6 - - go version
7 - - go env
8 -
9 -build_script:
10 - - cd %APPVEYOR_BUILD_FOLDER%
11 - - go vet ./...
12 - - go test -v ./...
13 -
14 -test: off
15 -
16 -deploy: off
Godeps/_workspace/src/github.com/codegangsta/cli/autocomplete/bash_autocomplete deleted
-14
@@ -1,14 +0,0 @@
1 -#! /bin/bash
2 -
3 -: ${PROG:=$(basename ${BASH_SOURCE})}
4 -
5 -_cli_bash_autocomplete() {
6 - local cur opts base
7 - COMPREPLY=()
8 - cur="${COMP_WORDS[COMP_CWORD]}"
9 - opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion )
10 - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
11 - return 0
12 - }
13 -
14 - complete -F _cli_bash_autocomplete $PROG
Godeps/_workspace/src/github.com/codegangsta/cli/autocomplete/zsh_autocomplete deleted
-5
@@ -1,5 +0,0 @@
1 -autoload -U compinit && compinit
2 -autoload -U bashcompinit && bashcompinit
3 -
4 -script_dir=$(dirname $0)
5 -source ${script_dir}/bash_autocomplete
Godeps/_workspace/src/github.com/codegangsta/cli/cli.go deleted
-40
@@ -1,40 +0,0 @@
1 -// Package cli provides a minimal framework for creating and organizing command line
2 -// Go applications. cli is designed to be easy to understand and write, the most simple
3 -// cli application can be written as follows:
4 -// func main() {
5 -// cli.NewApp().Run(os.Args)
6 -// }
7 -//
8 -// Of course this application does not do much, so let's make this an actual application:
9 -// func main() {
10 -// app := cli.NewApp()
11 -// app.Name = "greet"
12 -// app.Usage = "say a greeting"
13 -// app.Action = func(c *cli.Context) {
14 -// println("Greetings")
15 -// }
16 -//
17 -// app.Run(os.Args)
18 -// }
19 -package cli
20 -
21 -import (
22 - "strings"
23 -)
24 -
25 -type MultiError struct {
26 - Errors []error
27 -}
28 -
29 -func NewMultiError(err ...error) MultiError {
30 - return MultiError{Errors: err}
31 -}
32 -
33 -func (m MultiError) Error() string {
34 - errs := make([]string, len(m.Errors))
35 - for i, err := range m.Errors {
36 - errs[i] = err.Error()
37 - }
38 -
39 - return strings.Join(errs, "\n")
40 -}
Godeps/_workspace/src/github.com/codegangsta/cli/command.go deleted
-250
@@ -1,250 +0,0 @@
1 -package cli
2 -
3 -import (
4 - "fmt"
5 - "io/ioutil"
6 - "strings"
7 -)
8 -
9 -// Command is a subcommand for a cli.App.
10 -type Command struct {
11 - // The name of the command
12 - Name string
13 - // short name of the command. Typically one character (deprecated, use `Aliases`)
14 - ShortName string
15 - // A list of aliases for the command
16 - Aliases []string
17 - // A short description of the usage of this command
18 - Usage string
19 - // Custom text to show on USAGE section of help
20 - UsageText string
21 - // A longer explanation of how the command works
22 - Description string
23 - // A short description of the arguments of this command
24 - ArgsUsage string
25 - // The function to call when checking for bash command completions
26 - BashComplete func(context *Context)
27 - // An action to execute before any sub-subcommands are run, but after the context is ready
28 - // If a non-nil error is returned, no sub-subcommands are run
29 - Before func(context *Context) error
30 - // An action to execute after any subcommands are run, but before the subcommand has finished
31 - // It is run even if Action() panics
32 - After func(context *Context) error
33 - // The function to call when this command is invoked
34 - Action func(context *Context)
35 - // Execute this function, if an usage error occurs. This is useful for displaying customized usage error messages.
36 - // This function is able to replace the original error messages.
37 - // If this function is not set, the "Incorrect usage" is displayed and the execution is interrupted.
38 - OnUsageError func(context *Context, err error) error
39 - // List of child commands
40 - Subcommands []Command
41 - // List of flags to parse
42 - Flags []Flag
43 - // Treat all flags as normal arguments if true
44 - SkipFlagParsing bool
45 - // Boolean to hide built-in help command
46 - HideHelp bool
47 -
48 - // Full name of command for help, defaults to full command name, including parent commands.
49 - HelpName string
50 - commandNamePath []string
51 -}
52 -
53 -// Returns the full name of the command.
54 -// For subcommands this ensures that parent commands are part of the command path
55 -func (c Command) FullName() string {
56 - if c.commandNamePath == nil {
57 - return c.Name
58 - }
59 - return strings.Join(c.commandNamePath, " ")
60 -}
61 -
62 -// Invokes the command given the context, parses ctx.Args() to generate command-specific flags
63 -func (c Command) Run(ctx *Context) (err error) {
64 - if len(c.Subcommands) > 0 {
65 - return c.startApp(ctx)
66 - }
67 -
68 - if !c.HideHelp && (HelpFlag != BoolFlag{}) {
69 - // append help to flags
70 - c.Flags = append(
71 - c.Flags,
72 - HelpFlag,
73 - )
74 - }
75 -
76 - if ctx.App.EnableBashCompletion {
77 - c.Flags = append(c.Flags, BashCompletionFlag)
78 - }
79 -
80 - set := flagSet(c.Name, c.Flags)
81 - set.SetOutput(ioutil.Discard)
82 -
83 - if !c.SkipFlagParsing {
84 - firstFlagIndex := -1
85 - terminatorIndex := -1
86 - for index, arg := range ctx.Args() {
87 - if arg == "--" {
88 - terminatorIndex = index
89 - break
90 - } else if arg == "-" {
91 - // Do nothing. A dash alone is not really a flag.
92 - continue
93 - } else if strings.HasPrefix(arg, "-") && firstFlagIndex == -1 {
94 - firstFlagIndex = index
95 - }
96 - }
97 -
98 - if firstFlagIndex > -1 {
99 - args := ctx.Args()
100 - regularArgs := make([]string, len(args[1:firstFlagIndex]))
101 - copy(regularArgs, args[1:firstFlagIndex])
102 -
103 - var flagArgs []string
104 - if terminatorIndex > -1 {
105 - flagArgs = args[firstFlagIndex:terminatorIndex]
106 - regularArgs = append(regularArgs, args[terminatorIndex:]...)
107 - } else {
108 - flagArgs = args[firstFlagIndex:]
109 - }
110 -
111 - err = set.Parse(append(flagArgs, regularArgs...))
112 - } else {
113 - err = set.Parse(ctx.Args().Tail())
114 - }
115 - } else {
116 - if c.SkipFlagParsing {
117 - err = set.Parse(append([]string{"--"}, ctx.Args().Tail()...))
118 - }
119 - }
120 -
121 - if err != nil {
122 - if c.OnUsageError != nil {
123 - err := c.OnUsageError(ctx, err)
124 - return err
125 - } else {
126 - fmt.Fprintln(ctx.App.Writer, "Incorrect Usage.")
127 - fmt.Fprintln(ctx.App.Writer)
128 - ShowCommandHelp(ctx, c.Name)
129 - return err
130 - }
131 - }
132 -
133 - nerr := normalizeFlags(c.Flags, set)
134 - if nerr != nil {
135 - fmt.Fprintln(ctx.App.Writer, nerr)
136 - fmt.Fprintln(ctx.App.Writer)
137 - ShowCommandHelp(ctx, c.Name)
138 - return nerr
139 - }
140 - context := NewContext(ctx.App, set, ctx)
141 -
142 - if checkCommandCompletions(context, c.Name) {
143 - return nil
144 - }
145 -
146 - if checkCommandHelp(context, c.Name) {
147 - return nil
148 - }
149 -
150 - if c.After != nil {
151 - defer func() {
152 - afterErr := c.After(context)
153 - if afterErr != nil {
154 - if err != nil {
155 - err = NewMultiError(err, afterErr)
156 - } else {
157 - err = afterErr
158 - }
159 - }
160 - }()
161 - }
162 -
163 - if c.Before != nil {
164 - err := c.Before(context)
165 - if err != nil {
166 - fmt.Fprintln(ctx.App.Writer, err)
167 - fmt.Fprintln(ctx.App.Writer)
168 - ShowCommandHelp(ctx, c.Name)
169 - return err
170 - }
171 - }
172 -
173 - context.Command = c
174 - c.Action(context)
175 - return nil
176 -}
177 -
178 -func (c Command) Names() []string {
179 - names := []string{c.Name}
180 -
181 - if c.ShortName != "" {
182 - names = append(names, c.ShortName)
183 - }
184 -
185 - return append(names, c.Aliases...)
186 -}
187 -
188 -// Returns true if Command.Name or Command.ShortName matches given name
189 -func (c Command) HasName(name string) bool {
190 - for _, n := range c.Names() {
191 - if n == name {
192 - return true
193 - }
194 - }
195 - return false
196 -}
197 -
198 -func (c Command) startApp(ctx *Context) error {
199 - app := NewApp()
200 -
201 - // set the name and usage
202 - app.Name = fmt.Sprintf("%s %s", ctx.App.Name, c.Name)
203 - if c.HelpName == "" {
204 - app.HelpName = c.HelpName
205 - } else {
206 - app.HelpName = app.Name
207 - }
208 -
209 - if c.Description != "" {
210 - app.Usage = c.Description
211 - } else {
212 - app.Usage = c.Usage
213 - }
214 -
215 - // set CommandNotFound
216 - app.CommandNotFound = ctx.App.CommandNotFound
217 -
218 - // set the flags and commands
219 - app.Commands = c.Subcommands
220 - app.Flags = c.Flags
221 - app.HideHelp = c.HideHelp
222 -
223 - app.Version = ctx.App.Version
224 - app.HideVersion = ctx.App.HideVersion
225 - app.Compiled = ctx.App.Compiled
226 - app.Author = ctx.App.Author
227 - app.Email = ctx.App.Email
228 - app.Writer = ctx.App.Writer
229 -
230 - // bash completion
231 - app.EnableBashCompletion = ctx.App.EnableBashCompletion
232 - if c.BashComplete != nil {
233 - app.BashComplete = c.BashComplete
234 - }
235 -
236 - // set the actions
237 - app.Before = c.Before
238 - app.After = c.After
239 - if c.Action != nil {
240 - app.Action = c.Action
241 - } else {
242 - app.Action = helpSubcommand.Action
243 - }
244 -
245 - for index, cc := range app.Commands {
246 - app.Commands[index].commandNamePath = []string{c.Name, cc.Name}
247 - }
248 -
249 - return app.RunAsSubcommand(ctx)
250 -}
Godeps/_workspace/src/github.com/codegangsta/cli/command_test.go deleted
-97
@@ -1,97 +0,0 @@
1 -package cli
2 -
3 -import (
4 - "errors"
5 - "flag"
6 - "fmt"
7 - "io/ioutil"
8 - "strings"
9 - "testing"
10 -)
11 -
12 -func TestCommandFlagParsing(t *testing.T) {
13 - cases := []struct {
14 - testArgs []string
15 - skipFlagParsing bool
16 - expectedErr error
17 - }{
18 - {[]string{"blah", "blah", "-break"}, false, errors.New("flag provided but not defined: -break")}, // Test normal "not ignoring flags" flow
19 - {[]string{"blah", "blah"}, true, nil}, // Test SkipFlagParsing without any args that look like flags
20 - {[]string{"blah", "-break"}, true, nil}, // Test SkipFlagParsing with random flag arg
21 - {[]string{"blah", "-help"}, true, nil}, // Test SkipFlagParsing with "special" help flag arg
22 - }
23 -
24 - for _, c := range cases {
25 - app := NewApp()
26 - app.Writer = ioutil.Discard
27 - set := flag.NewFlagSet("test", 0)
28 - set.Parse(c.testArgs)
29 -
30 - context := NewContext(app, set, nil)
31 -
32 - command := Command{
33 - Name: "test-cmd",
34 - Aliases: []string{"tc"},
35 - Usage: "this is for testing",
36 - Description: "testing",
37 - Action: func(_ *Context) {},
38 - }
39 -
40 - command.SkipFlagParsing = c.skipFlagParsing
41 -
42 - err := command.Run(context)
43 -
44 - expect(t, err, c.expectedErr)
45 - expect(t, []string(context.Args()), c.testArgs)
46 - }
47 -}
48 -
49 -func TestCommand_Run_DoesNotOverwriteErrorFromBefore(t *testing.T) {
50 - app := NewApp()
51 - app.Commands = []Command{
52 - Command{
53 - Name: "bar",
54 - Before: func(c *Context) error { return fmt.Errorf("before error") },
55 - After: func(c *Context) error { return fmt.Errorf("after error") },
56 - },
57 - }
58 -
59 - err := app.Run([]string{"foo", "bar"})
60 - if err == nil {
61 - t.Fatalf("expected to receive error from Run, got none")
62 - }
63 -
64 - if !strings.Contains(err.Error(), "before error") {
65 - t.Errorf("expected text of error from Before method, but got none in \"%v\"", err)
66 - }
67 - if !strings.Contains(err.Error(), "after error") {
68 - t.Errorf("expected text of error from After method, but got none in \"%v\"", err)
69 - }
70 -}
71 -
72 -func TestCommand_OnUsageError_WithWrongFlagValue(t *testing.T) {
73 - app := NewApp()
74 - app.Commands = []Command{
75 - Command{
76 - Name: "bar",
77 - Flags: []Flag{
78 - IntFlag{Name: "flag"},
79 - },
80 - OnUsageError: func(c *Context, err error) error {
81 - if !strings.HasPrefix(err.Error(), "invalid value \"wrong\"") {
82 - t.Errorf("Expect an invalid value error, but got \"%v\"", err)
83 - }
84 - return errors.New("intercepted: " + err.Error())
85 - },
86 - },
87 - }
88 -
89 - err := app.Run([]string{"foo", "bar", "--flag=wrong"})
90 - if err == nil {
91 - t.Fatalf("expected to receive error from Run, got none")
92 - }
93 -
94 - if !strings.HasPrefix(err.Error(), "intercepted: invalid value") {
95 - t.Errorf("Expect an intercepted error, but got \"%v\"", err)
96 - }
97 -}
Godeps/_workspace/src/github.com/codegangsta/cli/context.go deleted
-393
@@ -1,393 +0,0 @@
1 -package cli
2 -
3 -import (
4 - "errors"
5 - "flag"
6 - "strconv"
7 - "strings"
8 - "time"
9 -)
10 -
11 -// Context is a type that is passed through to
12 -// each Handler action in a cli application. Context
13 -// can be used to retrieve context-specific Args and
14 -// parsed command-line options.
15 -type Context struct {
16 - App *App
17 - Command Command
18 - flagSet *flag.FlagSet
19 - setFlags map[string]bool
20 - globalSetFlags map[string]bool
21 - parentContext *Context
22 -}
23 -
24 -// Creates a new context. For use in when invoking an App or Command action.
25 -func NewContext(app *App, set *flag.FlagSet, parentCtx *Context) *Context {
26 - return &Context{App: app, flagSet: set, parentContext: parentCtx}
27 -}
28 -
29 -// Looks up the value of a local int flag, returns 0 if no int flag exists
30 -func (c *Context) Int(name string) int {
31 - return lookupInt(name, c.flagSet)
32 -}
33 -
34 -// Looks up the value of a local time.Duration flag, returns 0 if no time.Duration flag exists
35 -func (c *Context) Duration(name string) time.Duration {
36 - return lookupDuration(name, c.flagSet)
37 -}
38 -
39 -// Looks up the value of a local float64 flag, returns 0 if no float64 flag exists
40 -func (c *Context) Float64(name string) float64 {
41 - return lookupFloat64(name, c.flagSet)
42 -}
43 -
44 -// Looks up the value of a local bool flag, returns false if no bool flag exists
45 -func (c *Context) Bool(name string) bool {
46 - return lookupBool(name, c.flagSet)
47 -}
48 -
49 -// Looks up the value of a local boolT flag, returns false if no bool flag exists
50 -func (c *Context) BoolT(name string) bool {
51 - return lookupBoolT(name, c.flagSet)
52 -}
53 -
54 -// Looks up the value of a local string flag, returns "" if no string flag exists
55 -func (c *Context) String(name string) string {
56 - return lookupString(name, c.flagSet)
57 -}
58 -
59 -// Looks up the value of a local string slice flag, returns nil if no string slice flag exists
60 -func (c *Context) StringSlice(name string) []string {
61 - return lookupStringSlice(name, c.flagSet)
62 -}
63 -
64 -// Looks up the value of a local int slice flag, returns nil if no int slice flag exists
65 -func (c *Context) IntSlice(name string) []int {
66 - return lookupIntSlice(name, c.flagSet)
67 -}
68 -
69 -// Looks up the value of a local generic flag, returns nil if no generic flag exists
70 -func (c *Context) Generic(name string) interface{} {
71 - return lookupGeneric(name, c.flagSet)
72 -}
73 -
74 -// Looks up the value of a global int flag, returns 0 if no int flag exists
75 -func (c *Context) GlobalInt(name string) int {
76 - if fs := lookupGlobalFlagSet(name, c); fs != nil {
77 - return lookupInt(name, fs)
78 - }
79 - return 0
80 -}
81 -
82 -// Looks up the value of a global time.Duration flag, returns 0 if no time.Duration flag exists
83 -func (c *Context) GlobalDuration(name string) time.Duration {
84 - if fs := lookupGlobalFlagSet(name, c); fs != nil {
85 - return lookupDuration(name, fs)
86 - }
87 - return 0
88 -}
89 -
90 -// Looks up the value of a global bool flag, returns false if no bool flag exists
91 -func (c *Context) GlobalBool(name string) bool {
92 - if fs := lookupGlobalFlagSet(name, c); fs != nil {
93 - return lookupBool(name, fs)
94 - }
95 - return false
96 -}
97 -
98 -// Looks up the value of a global string flag, returns "" if no string flag exists
99 -func (c *Context) GlobalString(name string) string {
100 - if fs := lookupGlobalFlagSet(name, c); fs != nil {
101 - return lookupString(name, fs)
102 - }
103 - return ""
104 -}
105 -
106 -// Looks up the value of a global string slice flag, returns nil if no string slice flag exists
107 -func (c *Context) GlobalStringSlice(name string) []string {
108 - if fs := lookupGlobalFlagSet(name, c); fs != nil {
109 - return lookupStringSlice(name, fs)
110 - }
111 - return nil
112 -}
113 -
114 -// Looks up the value of a global int slice flag, returns nil if no int slice flag exists
115 -func (c *Context) GlobalIntSlice(name string) []int {
116 - if fs := lookupGlobalFlagSet(name, c); fs != nil {
117 - return lookupIntSlice(name, fs)
118 - }
119 - return nil
120 -}
121 -
122 -// Looks up the value of a global generic flag, returns nil if no generic flag exists
123 -func (c *Context) GlobalGeneric(name string) interface{} {
124 - if fs := lookupGlobalFlagSet(name, c); fs != nil {
125 - return lookupGeneric(name, fs)
126 - }
127 - return nil
128 -}
129 -
130 -// Returns the number of flags set
131 -func (c *Context) NumFlags() int {
132 - return c.flagSet.NFlag()
133 -}
134 -
135 -// Determines if the flag was actually set
136 -func (c *Context) IsSet(name string) bool {
137 - if c.setFlags == nil {
138 - c.setFlags = make(map[string]bool)
139 - c.flagSet.Visit(func(f *flag.Flag) {
140 - c.setFlags[f.Name] = true
141 - })
142 - }
143 - return c.setFlags[name] == true
144 -}
145 -
146 -// Determines if the global flag was actually set
147 -func (c *Context) GlobalIsSet(name string) bool {
148 - if c.globalSetFlags == nil {
149 - c.globalSetFlags = make(map[string]bool)
150 - ctx := c
151 - if ctx.parentContext != nil {
152 - ctx = ctx.parentContext
153 - }
154 - for ; ctx != nil && c.globalSetFlags[name] == false; ctx = ctx.parentContext {
155 - ctx.flagSet.Visit(func(f *flag.Flag) {
156 - c.globalSetFlags[f.Name] = true
157 - })
158 - }
159 - }
160 - return c.globalSetFlags[name]
161 -}
162 -
163 -// Returns a slice of flag names used in this context.
164 -func (c *Context) FlagNames() (names []string) {
165 - for _, flag := range c.Command.Flags {
166 - name := strings.Split(flag.GetName(), ",")[0]
167 - if name == "help" {
168 - continue
169 - }
170 - names = append(names, name)
171 - }
172 - return
173 -}
174 -
175 -// Returns a slice of global flag names used by the app.
176 -func (c *Context) GlobalFlagNames() (names []string) {
177 - for _, flag := range c.App.Flags {
178 - name := strings.Split(flag.GetName(), ",")[0]
179 - if name == "help" || name == "version" {
180 - continue
181 - }
182 - names = append(names, name)
183 - }
184 - return
185 -}
186 -
187 -// Returns the parent context, if any
188 -func (c *Context) Parent() *Context {
189 - return c.parentContext
190 -}
191 -
192 -type Args []string
193 -
194 -// Returns the command line arguments associated with the context.
195 -func (c *Context) Args() Args {
196 - args := Args(c.flagSet.Args())
197 - return args
198 -}
199 -
200 -// Returns the number of the command line arguments.
201 -func (c *Context) NArg() int {
202 - return len(c.Args())
203 -}
204 -
205 -// Returns the nth argument, or else a blank string
206 -func (a Args) Get(n int) string {
207 - if len(a) > n {
208 - return a[n]
209 - }
210 - return ""
211 -}
212 -
213 -// Returns the first argument, or else a blank string
214 -func (a Args) First() string {
215 - return a.Get(0)
216 -}
217 -
218 -// Return the rest of the arguments (not the first one)
219 -// or else an empty string slice
220 -func (a Args) Tail() []string {
221 - if len(a) >= 2 {
222 - return []string(a)[1:]
223 - }
224 - return []string{}
225 -}
226 -
227 -// Checks if there are any arguments present
228 -func (a Args) Present() bool {
229 - return len(a) != 0
230 -}
231 -
232 -// Swaps arguments at the given indexes
233 -func (a Args) Swap(from, to int) error {
234 - if from >= len(a) || to >= len(a) {
235 - return errors.New("index out of range")
236 - }
237 - a[from], a[to] = a[to], a[from]
238 - return nil
239 -}
240 -
241 -func lookupGlobalFlagSet(name string, ctx *Context) *flag.FlagSet {
242 - if ctx.parentContext != nil {
243 - ctx = ctx.parentContext
244 - }
245 - for ; ctx != nil; ctx = ctx.parentContext {
246 - if f := ctx.flagSet.Lookup(name); f != nil {
247 - return ctx.flagSet
248 - }
249 - }
250 - return nil
251 -}
252 -
253 -func lookupInt(name string, set *flag.FlagSet) int {
254 - f := set.Lookup(name)
255 - if f != nil {
256 - val, err := strconv.Atoi(f.Value.String())
257 - if err != nil {
258 - return 0
259 - }
260 - return val
261 - }
262 -
263 - return 0
264 -}
265 -
266 -func lookupDuration(name string, set *flag.FlagSet) time.Duration {
267 - f := set.Lookup(name)
268 - if f != nil {
269 - val, err := time.ParseDuration(f.Value.String())
270 - if err == nil {
271 - return val
272 - }
273 - }
274 -
275 - return 0
276 -}
277 -
278 -func lookupFloat64(name string, set *flag.FlagSet) float64 {
279 - f := set.Lookup(name)
280 - if f != nil {
281 - val, err := strconv.ParseFloat(f.Value.String(), 64)
282 - if err != nil {
283 - return 0
284 - }
285 - return val
286 - }
287 -
288 - return 0
289 -}
290 -
291 -func lookupString(name string, set *flag.FlagSet) string {
292 - f := set.Lookup(name)
293 - if f != nil {
294 - return f.Value.String()
295 - }
296 -
297 - return ""
298 -}
299 -
300 -func lookupStringSlice(name string, set *flag.FlagSet) []string {
301 - f := set.Lookup(name)
302 - if f != nil {
303 - return (f.Value.(*StringSlice)).Value()
304 -
305 - }
306 -
307 - return nil
308 -}
309 -
310 -func lookupIntSlice(name string, set *flag.FlagSet) []int {
311 - f := set.Lookup(name)
312 - if f != nil {
313 - return (f.Value.(*IntSlice)).Value()
314 -
315 - }
316 -
317 - return nil
318 -}
319 -
320 -func lookupGeneric(name string, set *flag.FlagSet) interface{} {
321 - f := set.Lookup(name)
322 - if f != nil {
323 - return f.Value
324 - }
325 - return nil
326 -}
327 -
328 -func lookupBool(name string, set *flag.FlagSet) bool {
329 - f := set.Lookup(name)
330 - if f != nil {
331 - val, err := strconv.ParseBool(f.Value.String())
332 - if err != nil {
333 - return false
334 - }
335 - return val
336 - }
337 -
338 - return false
339 -}
340 -
341 -func lookupBoolT(name string, set *flag.FlagSet) bool {
342 - f := set.Lookup(name)
343 - if f != nil {
344 - val, err := strconv.ParseBool(f.Value.String())
345 - if err != nil {
346 - return true
347 - }
348 - return val
349 - }
350 -
351 - return false
352 -}
353 -
354 -func copyFlag(name string, ff *flag.Flag, set *flag.FlagSet) {
355 - switch ff.Value.(type) {
356 - case *StringSlice:
357 - default:
358 - set.Set(name, ff.Value.String())
359 - }
360 -}
361 -
362 -func normalizeFlags(flags []Flag, set *flag.FlagSet) error {
363 - visited := make(map[string]bool)
364 - set.Visit(func(f *flag.Flag) {
365 - visited[f.Name] = true
366 - })
367 - for _, f := range flags {
368 - parts := strings.Split(f.GetName(), ",")
369 - if len(parts) == 1 {
370 - continue
371 - }
372 - var ff *flag.Flag
373 - for _, name := range parts {
374 - name = strings.Trim(name, " ")
375 - if visited[name] {
376 - if ff != nil {
377 - return errors.New("Cannot use two forms of the same flag: " + name + " " + ff.Name)
378 - }
379 - ff = set.Lookup(name)
380 - }
381 - }
382 - if ff == nil {
383 - continue
384 - }
385 - for _, name := range parts {
386 - name = strings.Trim(name, " ")
387 - if !visited[name] {
388 - copyFlag(name, ff, set)
389 - }
390 - }
391 - }
392 - return nil
393 -}
Godeps/_workspace/src/github.com/codegangsta/cli/context_test.go deleted
-121
@@ -1,121 +0,0 @@
1 -package cli
2 -
3 -import (
4 - "flag"
5 - "testing"
6 - "time"
7 -)
8 -
9 -func TestNewContext(t *testing.T) {
10 - set := flag.NewFlagSet("test", 0)
11 - set.Int("myflag", 12, "doc")
12 - globalSet := flag.NewFlagSet("test", 0)
13 - globalSet.Int("myflag", 42, "doc")
14 - globalCtx := NewContext(nil, globalSet, nil)
15 - command := Command{Name: "mycommand"}
16 - c := NewContext(nil, set, globalCtx)
17 - c.Command = command
18 - expect(t, c.Int("myflag"), 12)
19 - expect(t, c.GlobalInt("myflag"), 42)
20 - expect(t, c.Command.Name, "mycommand")
21 -}
22 -
23 -func TestContext_Int(t *testing.T) {
24 - set := flag.NewFlagSet("test", 0)
25 - set.Int("myflag", 12, "doc")
26 - c := NewContext(nil, set, nil)
27 - expect(t, c.Int("myflag"), 12)
28 -}
29 -
30 -func TestContext_Duration(t *testing.T) {
31 - set := flag.NewFlagSet("test", 0)
32 - set.Duration("myflag", time.Duration(12*time.Second), "doc")
33 - c := NewContext(nil, set, nil)
34 - expect(t, c.Duration("myflag"), time.Duration(12*time.Second))
35 -}
36 -
37 -func TestContext_String(t *testing.T) {
38 - set := flag.NewFlagSet("test", 0)
39 - set.String("myflag", "hello world", "doc")
40 - c := NewContext(nil, set, nil)
41 - expect(t, c.String("myflag"), "hello world")
42 -}
43 -
44 -func TestContext_Bool(t *testing.T) {
45 - set := flag.NewFlagSet("test", 0)
46 - set.Bool("myflag", false, "doc")
47 - c := NewContext(nil, set, nil)
48 - expect(t, c.Bool("myflag"), false)
49 -}
50 -
51 -func TestContext_BoolT(t *testing.T) {
52 - set := flag.NewFlagSet("test", 0)
53 - set.Bool("myflag", true, "doc")
54 - c := NewContext(nil, set, nil)
55 - expect(t, c.BoolT("myflag"), true)
56 -}
57 -
58 -func TestContext_Args(t *testing.T) {
59 - set := flag.NewFlagSet("test", 0)
60 - set.Bool("myflag", false, "doc")
61 - c := NewContext(nil, set, nil)
62 - set.Parse([]string{"--myflag", "bat", "baz"})
63 - expect(t, len(c.Args()), 2)
64 - expect(t, c.Bool("myflag"), true)
65 -}
66 -
67 -func TestContext_NArg(t *testing.T) {
68 - set := flag.NewFlagSet("test", 0)
69 - set.Bool("myflag", false, "doc")
70 - c := NewContext(nil, set, nil)
71 - set.Parse([]string{"--myflag", "bat", "baz"})
72 - expect(t, c.NArg(), 2)
73 -}
74 -
75 -func TestContext_IsSet(t *testing.T) {
76 - set := flag.NewFlagSet("test", 0)
77 - set.Bool("myflag", false, "doc")
78 - set.String("otherflag", "hello world", "doc")
79 - globalSet := flag.NewFlagSet("test", 0)
80 - globalSet.Bool("myflagGlobal", true, "doc")
81 - globalCtx := NewContext(nil, globalSet, nil)
82 - c := NewContext(nil, set, globalCtx)
83 - set.Parse([]string{"--myflag", "bat", "baz"})
84 - globalSet.Parse([]string{"--myflagGlobal", "bat", "baz"})
85 - expect(t, c.IsSet("myflag"), true)
86 - expect(t, c.IsSet("otherflag"), false)
87 - expect(t, c.IsSet("bogusflag"), false)
88 - expect(t, c.IsSet("myflagGlobal"), false)
89 -}
90 -
91 -func TestContext_GlobalIsSet(t *testing.T) {
92 - set := flag.NewFlagSet("test", 0)
93 - set.Bool("myflag", false, "doc")
94 - set.String("otherflag", "hello world", "doc")
95 - globalSet := flag.NewFlagSet("test", 0)
96 - globalSet.Bool("myflagGlobal", true, "doc")
97 - globalSet.Bool("myflagGlobalUnset", true, "doc")
98 - globalCtx := NewContext(nil, globalSet, nil)
99 - c := NewContext(nil, set, globalCtx)
100 - set.Parse([]string{"--myflag", "bat", "baz"})
101 - globalSet.Parse([]string{"--myflagGlobal", "bat", "baz"})
102 - expect(t, c.GlobalIsSet("myflag"), false)
103 - expect(t, c.GlobalIsSet("otherflag"), false)
104 - expect(t, c.GlobalIsSet("bogusflag"), false)
105 - expect(t, c.GlobalIsSet("myflagGlobal"), true)
106 - expect(t, c.GlobalIsSet("myflagGlobalUnset"), false)
107 - expect(t, c.GlobalIsSet("bogusGlobal"), false)
108 -}
109 -
110 -func TestContext_NumFlags(t *testing.T) {
111 - set := flag.NewFlagSet("test", 0)
112 - set.Bool("myflag", false, "doc")
113 - set.String("otherflag", "hello world", "doc")
114 - globalSet := flag.NewFlagSet("test", 0)
115 - globalSet.Bool("myflagGlobal", true, "doc")
116 - globalCtx := NewContext(nil, globalSet, nil)
117 - c := NewContext(nil, set, globalCtx)
118 - set.Parse([]string{"--myflag", "--otherflag=foo"})
119 - globalSet.Parse([]string{"--myflagGlobal"})
120 - expect(t, c.NumFlags(), 2)
121 -}
Godeps/_workspace/src/github.com/codegangsta/cli/flag.go deleted
-546
@@ -1,546 +0,0 @@
1 -package cli
2 -
3 -import (
4 - "flag"
5 - "fmt"
6 - "os"
7 - "runtime"
8 - "strconv"
9 - "strings"
10 - "time"
11 -)
12 -
13 -// This flag enables bash-completion for all commands and subcommands
14 -var BashCompletionFlag = BoolFlag{
15 - Name: "generate-bash-completion",
16 -}
17 -
18 -// This flag prints the version for the application
19 -var VersionFlag = BoolFlag{
20 - Name: "version, v",
21 - Usage: "print the version",
22 -}
23 -
24 -// This flag prints the help for all commands and subcommands
25 -// Set to the zero value (BoolFlag{}) to disable flag -- keeps subcommand
26 -// unless HideHelp is set to true)
27 -var HelpFlag = BoolFlag{
28 - Name: "help, h",
29 - Usage: "show help",
30 -}
31 -
32 -// Flag is a common interface related to parsing flags in cli.
33 -// For more advanced flag parsing techniques, it is recommended that
34 -// this interface be implemented.
35 -type Flag interface {
36 - fmt.Stringer
37 - // Apply Flag settings to the given flag set
38 - Apply(*flag.FlagSet)
39 - GetName() string
40 -}
41 -
42 -func flagSet(name string, flags []Flag) *flag.FlagSet {
43 - set := flag.NewFlagSet(name, flag.ContinueOnError)
44 -
45 - for _, f := range flags {
46 - f.Apply(set)
47 - }
48 - return set
49 -}
50 -
51 -func eachName(longName string, fn func(string)) {
52 - parts := strings.Split(longName, ",")
53 - for _, name := range parts {
54 - name = strings.Trim(name, " ")
55 - fn(name)
56 - }
57 -}
58 -
59 -// Generic is a generic parseable type identified by a specific flag
60 -type Generic interface {
61 - Set(value string) error
62 - String() string
63 -}
64 -
65 -// GenericFlag is the flag type for types implementing Generic
66 -type GenericFlag struct {
67 - Name string
68 - Value Generic
69 - Usage string
70 - EnvVar string
71 -}
72 -
73 -// String returns the string representation of the generic flag to display the
74 -// help text to the user (uses the String() method of the generic flag to show
75 -// the value)
76 -func (f GenericFlag) String() string {
77 - return withEnvHint(f.EnvVar, fmt.Sprintf("%s %v\t%v", prefixedNames(f.Name), f.FormatValueHelp(), f.Usage))
78 -}
79 -
80 -func (f GenericFlag) FormatValueHelp() string {
81 - if f.Value == nil {
82 - return ""
83 - }
84 - s := f.Value.String()
85 - if len(s) == 0 {
86 - return ""
87 - }
88 - return fmt.Sprintf("\"%s\"", s)
89 -}
90 -
91 -// Apply takes the flagset and calls Set on the generic flag with the value
92 -// provided by the user for parsing by the flag
93 -func (f GenericFlag) Apply(set *flag.FlagSet) {
94 - val := f.Value
95 - if f.EnvVar != "" {
96 - for _, envVar := range strings.Split(f.EnvVar, ",") {
97 - envVar = strings.TrimSpace(envVar)
98 - if envVal := os.Getenv(envVar); envVal != "" {
99 - val.Set(envVal)
100 - break
101 - }
102 - }
103 - }
104 -
105 - eachName(f.Name, func(name string) {
106 - set.Var(f.Value, name, f.Usage)
107 - })
108 -}
109 -
110 -func (f GenericFlag) GetName() string {
111 - return f.Name
112 -}
113 -
114 -// StringSlice is an opaque type for []string to satisfy flag.Value
115 -type StringSlice []string
116 -
117 -// Set appends the string value to the list of values
118 -func (f *StringSlice) Set(value string) error {
119 - *f = append(*f, value)
120 - return nil
121 -}
122 -
123 -// String returns a readable representation of this value (for usage defaults)
124 -func (f *StringSlice) String() string {
125 - return fmt.Sprintf("%s", *f)
126 -}
127 -
128 -// Value returns the slice of strings set by this flag
129 -func (f *StringSlice) Value() []string {
130 - return *f
131 -}
132 -
133 -// StringSlice is a string flag that can be specified multiple times on the
134 -// command-line
135 -type StringSliceFlag struct {
136 - Name string
137 - Value *StringSlice
138 - Usage string
139 - EnvVar string
140 -}
141 -
142 -// String returns the usage
143 -func (f StringSliceFlag) String() string {
144 - firstName := strings.Trim(strings.Split(f.Name, ",")[0], " ")
145 - pref := prefixFor(firstName)
146 - return withEnvHint(f.EnvVar, fmt.Sprintf("%s [%v]\t%v", prefixedNames(f.Name), pref+firstName+" option "+pref+firstName+" option", f.Usage))
147 -}
148 -
149 -// Apply populates the flag given the flag set and environment
150 -func (f StringSliceFlag) Apply(set *flag.FlagSet) {
151 - if f.EnvVar != "" {
152 - for _, envVar := range strings.Split(f.EnvVar, ",") {
153 - envVar = strings.TrimSpace(envVar)
154 - if envVal := os.Getenv(envVar); envVal != "" {
155 - newVal := &StringSlice{}
156 - for _, s := range strings.Split(envVal, ",") {
157 - s = strings.TrimSpace(s)
158 - newVal.Set(s)
159 - }
160 - f.Value = newVal
161 - break
162 - }
163 - }
164 - }
165 -
166 - eachName(f.Name, func(name string) {
167 - if f.Value == nil {
168 - f.Value = &StringSlice{}
169 - }
170 - set.Var(f.Value, name, f.Usage)
171 - })
172 -}
173 -
174 -func (f StringSliceFlag) GetName() string {
175 - return f.Name
176 -}
177 -
178 -// StringSlice is an opaque type for []int to satisfy flag.Value
179 -type IntSlice []int
180 -
181 -// Set parses the value into an integer and appends it to the list of values
182 -func (f *IntSlice) Set(value string) error {
183 - tmp, err := strconv.Atoi(value)
184 - if err != nil {
185 - return err
186 - } else {
187 - *f = append(*f, tmp)
188 - }
189 - return nil
190 -}
191 -
192 -// String returns a readable representation of this value (for usage defaults)
193 -func (f *IntSlice) String() string {
194 - return fmt.Sprintf("%d", *f)
195 -}
196 -
197 -// Value returns the slice of ints set by this flag
198 -func (f *IntSlice) Value() []int {
199 - return *f
200 -}
201 -
202 -// IntSliceFlag is an int flag that can be specified multiple times on the
203 -// command-line
204 -type IntSliceFlag struct {
205 - Name string
206 - Value *IntSlice
207 - Usage string
208 - EnvVar string
209 -}
210 -
211 -// String returns the usage
212 -func (f IntSliceFlag) String() string {
213 - firstName := strings.Trim(strings.Split(f.Name, ",")[0], " ")
214 - pref := prefixFor(firstName)
215 - return withEnvHint(f.EnvVar, fmt.Sprintf("%s [%v]\t%v", prefixedNames(f.Name), pref+firstName+" option "+pref+firstName+" option", f.Usage))
216 -}
217 -
218 -// Apply populates the flag given the flag set and environment
219 -func (f IntSliceFlag) Apply(set *flag.FlagSet) {
220 - if f.EnvVar != "" {
221 - for _, envVar := range strings.Split(f.EnvVar, ",") {
222 - envVar = strings.TrimSpace(envVar)
223 - if envVal := os.Getenv(envVar); envVal != "" {
224 - newVal := &IntSlice{}
225 - for _, s := range strings.Split(envVal, ",") {
226 - s = strings.TrimSpace(s)
227 - err := newVal.Set(s)
228 - if err != nil {
229 - fmt.Fprintf(os.Stderr, err.Error())
230 - }
231 - }
232 - f.Value = newVal
233 - break
234 - }
235 - }
236 - }
237 -
238 - eachName(f.Name, func(name string) {
239 - if f.Value == nil {
240 - f.Value = &IntSlice{}
241 - }
242 - set.Var(f.Value, name, f.Usage)
243 - })
244 -}
245 -
246 -func (f IntSliceFlag) GetName() string {
247 - return f.Name
248 -}
249 -
250 -// BoolFlag is a switch that defaults to false
251 -type BoolFlag struct {
252 - Name string
253 - Usage string
254 - EnvVar string
255 - Destination *bool
256 -}
257 -
258 -// String returns a readable representation of this value (for usage defaults)
259 -func (f BoolFlag) String() string {
260 - return withEnvHint(f.EnvVar, fmt.Sprintf("%s\t%v", prefixedNames(f.Name), f.Usage))
261 -}
262 -
263 -// Apply populates the flag given the flag set and environment
264 -func (f BoolFlag) Apply(set *flag.FlagSet) {
265 - val := false
266 - if f.EnvVar != "" {
267 - for _, envVar := range strings.Split(f.EnvVar, ",") {
268 - envVar = strings.TrimSpace(envVar)
269 - if envVal := os.Getenv(envVar); envVal != "" {
270 - envValBool, err := strconv.ParseBool(envVal)
271 - if err == nil {
272 - val = envValBool
273 - }
274 - break
275 - }
276 - }
277 - }
278 -
279 - eachName(f.Name, func(name string) {
280 - if f.Destination != nil {
281 - set.BoolVar(f.Destination, name, val, f.Usage)
282 - return
283 - }
284 - set.Bool(name, val, f.Usage)
285 - })
286 -}
287 -
288 -func (f BoolFlag) GetName() string {
289 - return f.Name
290 -}
291 -
292 -// BoolTFlag this represents a boolean flag that is true by default, but can
293 -// still be set to false by --some-flag=false
294 -type BoolTFlag struct {
295 - Name string
296 - Usage string
297 - EnvVar string
298 - Destination *bool
299 -}
300 -
301 -// String returns a readable representation of this value (for usage defaults)
302 -func (f BoolTFlag) String() string {
303 - return withEnvHint(f.EnvVar, fmt.Sprintf("%s\t%v", prefixedNames(f.Name), f.Usage))
304 -}
305 -
306 -// Apply populates the flag given the flag set and environment
307 -func (f BoolTFlag) Apply(set *flag.FlagSet) {
308 - val := true
309 - if f.EnvVar != "" {
310 - for _, envVar := range strings.Split(f.EnvVar, ",") {
311 - envVar = strings.TrimSpace(envVar)
312 - if envVal := os.Getenv(envVar); envVal != "" {
313 - envValBool, err := strconv.ParseBool(envVal)
314 - if err == nil {
315 - val = envValBool
316 - break
317 - }
318 - }
319 - }
320 - }
321 -
322 - eachName(f.Name, func(name string) {
323 - if f.Destination != nil {
324 - set.BoolVar(f.Destination, name, val, f.Usage)
325 - return
326 - }
327 - set.Bool(name, val, f.Usage)
328 - })
329 -}
330 -
331 -func (f BoolTFlag) GetName() string {
332 - return f.Name
333 -}
334 -
335 -// StringFlag represents a flag that takes as string value
336 -type StringFlag struct {
337 - Name string
338 - Value string
339 - Usage string
340 - EnvVar string
341 - Destination *string
342 -}
343 -
344 -// String returns the usage
345 -func (f StringFlag) String() string {
346 - return withEnvHint(f.EnvVar, fmt.Sprintf("%s %v\t%v", prefixedNames(f.Name), f.FormatValueHelp(), f.Usage))
347 -}
348 -
349 -func (f StringFlag) FormatValueHelp() string {
350 - s := f.Value
351 - if len(s) == 0 {
352 - return ""
353 - }
354 - return fmt.Sprintf("\"%s\"", s)
355 -}
356 -
357 -// Apply populates the flag given the flag set and environment
358 -func (f StringFlag) Apply(set *flag.FlagSet) {
359 - if f.EnvVar != "" {
360 - for _, envVar := range strings.Split(f.EnvVar, ",") {
361 - envVar = strings.TrimSpace(envVar)
362 - if envVal := os.Getenv(envVar); envVal != "" {
363 - f.Value = envVal
364 - break
365 - }
366 - }
367 - }
368 -
369 - eachName(f.Name, func(name string) {
370 - if f.Destination != nil {
371 - set.StringVar(f.Destination, name, f.Value, f.Usage)
372 - return
373 - }
374 - set.String(name, f.Value, f.Usage)
375 - })
376 -}
377 -
378 -func (f StringFlag) GetName() string {
379 - return f.Name
380 -}
381 -
382 -// IntFlag is a flag that takes an integer
383 -// Errors if the value provided cannot be parsed
384 -type IntFlag struct {
385 - Name string
386 - Value int
387 - Usage string
388 - EnvVar string
389 - Destination *int
390 -}
391 -
392 -// String returns the usage
393 -func (f IntFlag) String() string {
394 - return withEnvHint(f.EnvVar, fmt.Sprintf("%s \"%v\"\t%v", prefixedNames(f.Name), f.Value, f.Usage))
395 -}
396 -
397 -// Apply populates the flag given the flag set and environment
398 -func (f IntFlag) Apply(set *flag.FlagSet) {
399 - if f.EnvVar != "" {
400 - for _, envVar := range strings.Split(f.EnvVar, ",") {
401 - envVar = strings.TrimSpace(envVar)
402 - if envVal := os.Getenv(envVar); envVal != "" {
403 - envValInt, err := strconv.ParseInt(envVal, 0, 64)
404 - if err == nil {
405 - f.Value = int(envValInt)
406 - break
407 - }
408 - }
409 - }
410 - }
411 -
412 - eachName(f.Name, func(name string) {
413 - if f.Destination != nil {
414 - set.IntVar(f.Destination, name, f.Value, f.Usage)
415 - return
416 - }
417 - set.Int(name, f.Value, f.Usage)
418 - })
419 -}
420 -
421 -func (f IntFlag) GetName() string {
422 - return f.Name
423 -}
424 -
425 -// DurationFlag is a flag that takes a duration specified in Go's duration
426 -// format: https://golang.org/pkg/time/#ParseDuration
427 -type DurationFlag struct {
428 - Name string
429 - Value time.Duration
430 - Usage string
431 - EnvVar string
432 - Destination *time.Duration
433 -}
434 -
435 -// String returns a readable representation of this value (for usage defaults)
436 -func (f DurationFlag) String() string {
437 - return withEnvHint(f.EnvVar, fmt.Sprintf("%s \"%v\"\t%v", prefixedNames(f.Name), f.Value, f.Usage))
438 -}
439 -
440 -// Apply populates the flag given the flag set and environment
441 -func (f DurationFlag) Apply(set *flag.FlagSet) {
442 - if f.EnvVar != "" {
443 - for _, envVar := range strings.Split(f.EnvVar, ",") {
444 - envVar = strings.TrimSpace(envVar)
445 - if envVal := os.Getenv(envVar); envVal != "" {
446 - envValDuration, err := time.ParseDuration(envVal)
447 - if err == nil {
448 - f.Value = envValDuration
449 - break
450 - }
451 - }
452 - }
453 - }
454 -
455 - eachName(f.Name, func(name string) {
456 - if f.Destination != nil {
457 - set.DurationVar(f.Destination, name, f.Value, f.Usage)
458 - return
459 - }
460 - set.Duration(name, f.Value, f.Usage)
461 - })
462 -}
463 -
464 -func (f DurationFlag) GetName() string {
465 - return f.Name
466 -}
467 -
468 -// Float64Flag is a flag that takes an float value
469 -// Errors if the value provided cannot be parsed
470 -type Float64Flag struct {
471 - Name string
472 - Value float64
473 - Usage string
474 - EnvVar string
475 - Destination *float64
476 -}
477 -
478 -// String returns the usage
479 -func (f Float64Flag) String() string {
480 - return withEnvHint(f.EnvVar, fmt.Sprintf("%s \"%v\"\t%v", prefixedNames(f.Name), f.Value, f.Usage))
481 -}
482 -
483 -// Apply populates the flag given the flag set and environment
484 -func (f Float64Flag) Apply(set *flag.FlagSet) {
485 - if f.EnvVar != "" {
486 - for _, envVar := range strings.Split(f.EnvVar, ",") {
487 - envVar = strings.TrimSpace(envVar)
488 - if envVal := os.Getenv(envVar); envVal != "" {
489 - envValFloat, err := strconv.ParseFloat(envVal, 10)
490 - if err == nil {
491 - f.Value = float64(envValFloat)
492 - }
493 - }
494 - }
495 - }
496 -
497 - eachName(f.Name, func(name string) {
498 - if f.Destination != nil {
499 - set.Float64Var(f.Destination, name, f.Value, f.Usage)
500 - return
501 - }
502 - set.Float64(name, f.Value, f.Usage)
503 - })
504 -}
505 -
506 -func (f Float64Flag) GetName() string {
507 - return f.Name
508 -}
509 -
510 -func prefixFor(name string) (prefix string) {
511 - if len(name) == 1 {
512 - prefix = "-"
513 - } else {
514 - prefix = "--"
515 - }
516 -
517 - return
518 -}
519 -
520 -func prefixedNames(fullName string) (prefixed string) {
521 - parts := strings.Split(fullName, ",")
522 - for i, name := range parts {
523 - name = strings.Trim(name, " ")
524 - prefixed += prefixFor(name) + name
525 - if i < len(parts)-1 {
526 - prefixed += ", "
527 - }
528 - }
529 - return
530 -}
531 -
532 -func withEnvHint(envVar, str string) string {
533 - envText := ""
534 - if envVar != "" {
535 - prefix := "$"
536 - suffix := ""
537 - sep := ", $"
538 - if runtime.GOOS == "windows" {
539 - prefix = "%"
540 - suffix = "%"
541 - sep = "%, %"
542 - }
543 - envText = fmt.Sprintf(" [%s%s%s]", prefix, strings.Join(strings.Split(envVar, ","), sep), suffix)
544 - }
545 - return str + envText
546 -}
Godeps/_workspace/src/github.com/codegangsta/cli/flag_test.go deleted
-859
@@ -1,859 +0,0 @@
1 -package cli
2 -
3 -import (
4 - "fmt"
5 - "os"
6 - "reflect"
7 - "strings"
8 - "testing"
9 - "runtime"
10 -)
11 -
12 -var boolFlagTests = []struct {
13 - name string
14 - expected string
15 -}{
16 - {"help", "--help\t"},
17 - {"h", "-h\t"},
18 -}
19 -
20 -func TestBoolFlagHelpOutput(t *testing.T) {
21 -
22 - for _, test := range boolFlagTests {
23 - flag := BoolFlag{Name: test.name}
24 - output := flag.String()
25 -
26 - if output != test.expected {
27 - t.Errorf("%s does not match %s", output, test.expected)
28 - }
29 - }
30 -}
31 -
32 -var stringFlagTests = []struct {
33 - name string
34 - value string
35 - expected string
36 -}{
37 - {"help", "", "--help \t"},
38 - {"h", "", "-h \t"},
39 - {"h", "", "-h \t"},
40 - {"test", "Something", "--test \"Something\"\t"},
41 -}
42 -
43 -func TestStringFlagHelpOutput(t *testing.T) {
44 -
45 - for _, test := range stringFlagTests {
46 - flag := StringFlag{Name: test.name, Value: test.value}
47 - output := flag.String()
48 -
49 - if output != test.expected {
50 - t.Errorf("%s does not match %s", output, test.expected)
51 - }
52 - }
53 -}
54 -
55 -func TestStringFlagWithEnvVarHelpOutput(t *testing.T) {
56 - os.Clearenv()
57 - os.Setenv("APP_FOO", "derp")
58 - for _, test := range stringFlagTests {
59 - flag := StringFlag{Name: test.name, Value: test.value, EnvVar: "APP_FOO"}
60 - output := flag.String()
61 -
62 - expectedSuffix := " [$APP_FOO]"
63 - if runtime.GOOS == "windows" {
64 - expectedSuffix = " [%APP_FOO%]"
65 - }
66 - if !strings.HasSuffix(output, expectedSuffix) {
67 - t.Errorf("%s does not end with" + expectedSuffix, output)
68 - }
69 - }
70 -}
71 -
72 -var stringSliceFlagTests = []struct {
73 - name string
74 - value *StringSlice
75 - expected string
76 -}{
77 - {"help", func() *StringSlice {
78 - s := &StringSlice{}
79 - s.Set("")
80 - return s
81 - }(), "--help [--help option --help option]\t"},
82 - {"h", func() *StringSlice {
83 - s := &StringSlice{}
84 - s.Set("")
85 - return s
86 - }(), "-h [-h option -h option]\t"},
87 - {"h", func() *StringSlice {
88 - s := &StringSlice{}
89 - s.Set("")
90 - return s
91 - }(), "-h [-h option -h option]\t"},
92 - {"test", func() *StringSlice {
93 - s := &StringSlice{}
94 - s.Set("Something")
95 - return s
96 - }(), "--test [--test option --test option]\t"},
97 -}
98 -
99 -func TestStringSliceFlagHelpOutput(t *testing.T) {
100 -
101 - for _, test := range stringSliceFlagTests {
102 - flag := StringSliceFlag{Name: test.name, Value: test.value}
103 - output := flag.String()
104 -
105 - if output != test.expected {
106 - t.Errorf("%q does not match %q", output, test.expected)
107 - }
108 - }
109 -}
110 -
111 -func TestStringSliceFlagWithEnvVarHelpOutput(t *testing.T) {
112 - os.Clearenv()
113 - os.Setenv("APP_QWWX", "11,4")
114 - for _, test := range stringSliceFlagTests {
115 - flag := StringSliceFlag{Name: test.name, Value: test.value, EnvVar: "APP_QWWX"}
116 - output := flag.String()
117 -
118 - expectedSuffix := " [$APP_QWWX]"
119 - if runtime.GOOS == "windows" {
120 - expectedSuffix = " [%APP_QWWX%]"
121 - }
122 - if !strings.HasSuffix(output, expectedSuffix) {
123 - t.Errorf("%q does not end with" + expectedSuffix, output)
124 - }
125 - }
126 -}
127 -
128 -var intFlagTests = []struct {
129 - name string
130 - expected string
131 -}{
132 - {"help", "--help \"0\"\t"},
133 - {"h", "-h \"0\"\t"},
134 -}
135 -
136 -func TestIntFlagHelpOutput(t *testing.T) {
137 -
138 - for _, test := range intFlagTests {
139 - flag := IntFlag{Name: test.name}
140 - output := flag.String()
141 -
142 - if output != test.expected {
143 - t.Errorf("%s does not match %s", output, test.expected)
144 - }
145 - }
146 -}
147 -
148 -func TestIntFlagWithEnvVarHelpOutput(t *testing.T) {
149 - os.Clearenv()
150 - os.Setenv("APP_BAR", "2")
151 - for _, test := range intFlagTests {
152 - flag := IntFlag{Name: test.name, EnvVar: "APP_BAR"}
153 - output := flag.String()
154 -
155 - expectedSuffix := " [$APP_BAR]"
156 - if runtime.GOOS == "windows" {
157 - expectedSuffix = " [%APP_BAR%]"
158 - }
159 - if !strings.HasSuffix(output, expectedSuffix) {
160 - t.Errorf("%s does not end with" + expectedSuffix, output)
161 - }
162 - }
163 -}
164 -
165 -var durationFlagTests = []struct {
166 - name string
167 - expected string
168 -}{
169 - {"help", "--help \"0\"\t"},
170 - {"h", "-h \"0\"\t"},
171 -}
172 -
173 -func TestDurationFlagHelpOutput(t *testing.T) {
174 -
175 - for _, test := range durationFlagTests {
176 - flag := DurationFlag{Name: test.name}
177 - output := flag.String()
178 -
179 - if output != test.expected {
180 - t.Errorf("%s does not match %s", output, test.expected)
181 - }
182 - }
183 -}
184 -
185 -func TestDurationFlagWithEnvVarHelpOutput(t *testing.T) {
186 - os.Clearenv()
187 - os.Setenv("APP_BAR", "2h3m6s")
188 - for _, test := range durationFlagTests {
189 - flag := DurationFlag{Name: test.name, EnvVar: "APP_BAR"}
190 - output := flag.String()
191 -
192 - expectedSuffix := " [$APP_BAR]"
193 - if runtime.GOOS == "windows" {
194 - expectedSuffix = " [%APP_BAR%]"
195 - }
196 - if !strings.HasSuffix(output, expectedSuffix) {
197 - t.Errorf("%s does not end with" + expectedSuffix, output)
198 - }
199 - }
200 -}
201 -
202 -var intSliceFlagTests = []struct {
203 - name string
204 - value *IntSlice
205 - expected string
206 -}{
207 - {"help", &IntSlice{}, "--help [--help option --help option]\t"},
208 - {"h", &IntSlice{}, "-h [-h option -h option]\t"},
209 - {"h", &IntSlice{}, "-h [-h option -h option]\t"},
210 - {"test", func() *IntSlice {
211 - i := &IntSlice{}
212 - i.Set("9")
213 - return i
214 - }(), "--test [--test option --test option]\t"},
215 -}
216 -
217 -func TestIntSliceFlagHelpOutput(t *testing.T) {
218 -
219 - for _, test := range intSliceFlagTests {
220 - flag := IntSliceFlag{Name: test.name, Value: test.value}
221 - output := flag.String()
222 -
223 - if output != test.expected {
224 - t.Errorf("%q does not match %q", output, test.expected)
225 - }
226 - }
227 -}
228 -
229 -func TestIntSliceFlagWithEnvVarHelpOutput(t *testing.T) {
230 - os.Clearenv()
231 - os.Setenv("APP_SMURF", "42,3")
232 - for _, test := range intSliceFlagTests {
233 - flag := IntSliceFlag{Name: test.name, Value: test.value, EnvVar: "APP_SMURF"}
234 - output := flag.String()
235 -
236 - expectedSuffix := " [$APP_SMURF]"
237 - if runtime.GOOS == "windows" {
238 - expectedSuffix = " [%APP_SMURF%]"
239 - }
240 - if !strings.HasSuffix(output, expectedSuffix) {
241 - t.Errorf("%q does not end with" + expectedSuffix, output)
242 - }
243 - }
244 -}
245 -
246 -var float64FlagTests = []struct {
247 - name string
248 - expected string
249 -}{
250 - {"help", "--help \"0\"\t"},
251 - {"h", "-h \"0\"\t"},
252 -}
253 -
254 -func TestFloat64FlagHelpOutput(t *testing.T) {
255 -
256 - for _, test := range float64FlagTests {
257 - flag := Float64Flag{Name: test.name}
258 - output := flag.String()
259 -
260 - if output != test.expected {
261 - t.Errorf("%s does not match %s", output, test.expected)
262 - }
263 - }
264 -}
265 -
266 -func TestFloat64FlagWithEnvVarHelpOutput(t *testing.T) {
267 - os.Clearenv()
268 - os.Setenv("APP_BAZ", "99.4")
269 - for _, test := range float64FlagTests {
270 - flag := Float64Flag{Name: test.name, EnvVar: "APP_BAZ"}
271 - output := flag.String()
272 -
273 - expectedSuffix := " [$APP_BAZ]"
274 - if runtime.GOOS == "windows" {
275 - expectedSuffix = " [%APP_BAZ%]"
276 - }
277 - if !strings.HasSuffix(output, expectedSuffix) {
278 - t.Errorf("%s does not end with" + expectedSuffix, output)
279 - }
280 - }
281 -}
282 -
283 -var genericFlagTests = []struct {
284 - name string
285 - value Generic
286 - expected string
287 -}{
288 - {"test", &Parser{"abc", "def"}, "--test \"abc,def\"\ttest flag"},
289 - {"t", &Parser{"abc", "def"}, "-t \"abc,def\"\ttest flag"},
290 -}
291 -
292 -func TestGenericFlagHelpOutput(t *testing.T) {
293 -
294 - for _, test := range genericFlagTests {
295 - flag := GenericFlag{Name: test.name, Value: test.value, Usage: "test flag"}
296 - output := flag.String()
297 -
298 - if output != test.expected {
299 - t.Errorf("%q does not match %q", output, test.expected)
300 - }
301 - }
302 -}
303 -
304 -func TestGenericFlagWithEnvVarHelpOutput(t *testing.T) {
305 - os.Clearenv()
306 - os.Setenv("APP_ZAP", "3")
307 - for _, test := range genericFlagTests {
308 - flag := GenericFlag{Name: test.name, EnvVar: "APP_ZAP"}
309 - output := flag.String()
310 -
311 - expectedSuffix := " [$APP_ZAP]"
312 - if runtime.GOOS == "windows" {
313 - expectedSuffix = " [%APP_ZAP%]"
314 - }
315 - if !strings.HasSuffix(output, expectedSuffix) {
316 - t.Errorf("%s does not end with" + expectedSuffix, output)
317 - }
318 - }
319 -}
320 -
321 -func TestParseMultiString(t *testing.T) {
322 - (&App{
323 - Flags: []Flag{
324 - StringFlag{Name: "serve, s"},
325 - },
326 - Action: func(ctx *Context) {
327 - if ctx.String("serve") != "10" {
328 - t.Errorf("main name not set")
329 - }
330 - if ctx.String("s") != "10" {
331 - t.Errorf("short name not set")
332 - }
333 - },
334 - }).Run([]string{"run", "-s", "10"})
335 -}
336 -
337 -func TestParseDestinationString(t *testing.T) {
338 - var dest string
339 - a := App{
340 - Flags: []Flag{
341 - StringFlag{
342 - Name: "dest",
343 - Destination: &dest,
344 - },
345 - },
346 - Action: func(ctx *Context) {
347 - if dest != "10" {
348 - t.Errorf("expected destination String 10")
349 - }
350 - },
351 - }
352 - a.Run([]string{"run", "--dest", "10"})
353 -}
354 -
355 -func TestParseMultiStringFromEnv(t *testing.T) {
356 - os.Clearenv()
357 - os.Setenv("APP_COUNT", "20")
358 - (&App{
359 - Flags: []Flag{
360 - StringFlag{Name: "count, c", EnvVar: "APP_COUNT"},
361 - },
362 - Action: func(ctx *Context) {
363 - if ctx.String("count") != "20" {
364 - t.Errorf("main name not set")
365 - }
366 - if ctx.String("c") != "20" {
367 - t.Errorf("short name not set")
368 - }
369 - },
370 - }).Run([]string{"run"})
371 -}
372 -
373 -func TestParseMultiStringFromEnvCascade(t *testing.T) {
374 - os.Clearenv()
375 - os.Setenv("APP_COUNT", "20")
376 - (&App{
377 - Flags: []Flag{
378 - StringFlag{Name: "count, c", EnvVar: "COMPAT_COUNT,APP_COUNT"},
379 - },
380 - Action: func(ctx *Context) {
381 - if ctx.String("count") != "20" {
382 - t.Errorf("main name not set")
383 - }
384 - if ctx.String("c") != "20" {
385 - t.Errorf("short name not set")
386 - }
387 - },
388 - }).Run([]string{"run"})
389 -}
390 -
391 -func TestParseMultiStringSlice(t *testing.T) {
392 - (&App{
393 - Flags: []Flag{
394 - StringSliceFlag{Name: "serve, s", Value: &StringSlice{}},
395 - },
396 - Action: func(ctx *Context) {
397 - if !reflect.DeepEqual(ctx.StringSlice("serve"), []string{"10", "20"}) {
398 - t.Errorf("main name not set")
399 - }
400 - if !reflect.DeepEqual(ctx.StringSlice("s"), []string{"10", "20"}) {
401 - t.Errorf("short name not set")
402 - }
403 - },
404 - }).Run([]string{"run", "-s", "10", "-s", "20"})
405 -}
406 -
407 -func TestParseMultiStringSliceFromEnv(t *testing.T) {
408 - os.Clearenv()
409 - os.Setenv("APP_INTERVALS", "20,30,40")
410 -
411 - (&App{
412 - Flags: []Flag{
413 - StringSliceFlag{Name: "intervals, i", Value: &StringSlice{}, EnvVar: "APP_INTERVALS"},
414 - },
415 - Action: func(ctx *Context) {
416 - if !reflect.DeepEqual(ctx.StringSlice("intervals"), []string{"20", "30", "40"}) {
417 - t.Errorf("main name not set from env")
418 - }
419 - if !reflect.DeepEqual(ctx.StringSlice("i"), []string{"20", "30", "40"}) {
420 - t.Errorf("short name not set from env")
421 - }
422 - },
423 - }).Run([]string{"run"})
424 -}
425 -
426 -func TestParseMultiStringSliceFromEnvCascade(t *testing.T) {
427 - os.Clearenv()
428 - os.Setenv("APP_INTERVALS", "20,30,40")
429 -
430 - (&App{
431 - Flags: []Flag{
432 - StringSliceFlag{Name: "intervals, i", Value: &StringSlice{}, EnvVar: "COMPAT_INTERVALS,APP_INTERVALS"},
433 - },
434 - Action: func(ctx *Context) {
435 - if !reflect.DeepEqual(ctx.StringSlice("intervals"), []string{"20", "30", "40"}) {
436 - t.Errorf("main name not set from env")
437 - }
438 - if !reflect.DeepEqual(ctx.StringSlice("i"), []string{"20", "30", "40"}) {
439 - t.Errorf("short name not set from env")
440 - }
441 - },
442 - }).Run([]string{"run"})
443 -}
444 -
445 -func TestParseMultiInt(t *testing.T) {
446 - a := App{
447 - Flags: []Flag{
448 - IntFlag{Name: "serve, s"},
449 - },
450 - Action: func(ctx *Context) {
451 - if ctx.Int("serve") != 10 {
452 - t.Errorf("main name not set")
453 - }
454 - if ctx.Int("s") != 10 {
455 - t.Errorf("short name not set")
456 - }
457 - },
458 - }
459 - a.Run([]string{"run", "-s", "10"})
460 -}
461 -
462 -func TestParseDestinationInt(t *testing.T) {
463 - var dest int
464 - a := App{
465 - Flags: []Flag{
466 - IntFlag{
467 - Name: "dest",
468 - Destination: &dest,
469 - },
470 - },
471 - Action: func(ctx *Context) {
472 - if dest != 10 {
473 - t.Errorf("expected destination Int 10")
474 - }
475 - },
476 - }
477 - a.Run([]string{"run", "--dest", "10"})
478 -}
479 -
480 -func TestParseMultiIntFromEnv(t *testing.T) {
481 - os.Clearenv()
482 - os.Setenv("APP_TIMEOUT_SECONDS", "10")
483 - a := App{
484 - Flags: []Flag{
485 - IntFlag{Name: "timeout, t", EnvVar: "APP_TIMEOUT_SECONDS"},
486 - },
487 - Action: func(ctx *Context) {
488 - if ctx.Int("timeout") != 10 {
489 - t.Errorf("main name not set")
490 - }
491 - if ctx.Int("t") != 10 {
492 - t.Errorf("short name not set")
493 - }
494 - },
495 - }
496 - a.Run([]string{"run"})
497 -}
498 -
499 -func TestParseMultiIntFromEnvCascade(t *testing.T) {
500 - os.Clearenv()
501 - os.Setenv("APP_TIMEOUT_SECONDS", "10")
502 - a := App{
503 - Flags: []Flag{
504 - IntFlag{Name: "timeout, t", EnvVar: "COMPAT_TIMEOUT_SECONDS,APP_TIMEOUT_SECONDS"},
505 - },
506 - Action: func(ctx *Context) {
507 - if ctx.Int("timeout") != 10 {
508 - t.Errorf("main name not set")
509 - }
510 - if ctx.Int("t") != 10 {
511 - t.Errorf("short name not set")
512 - }
513 - },
514 - }
515 - a.Run([]string{"run"})
516 -}
517 -
518 -func TestParseMultiIntSlice(t *testing.T) {
519 - (&App{
520 - Flags: []Flag{
521 - IntSliceFlag{Name: "serve, s", Value: &IntSlice{}},
522 - },
523 - Action: func(ctx *Context) {
524 - if !reflect.DeepEqual(ctx.IntSlice("serve"), []int{10, 20}) {
525 - t.Errorf("main name not set")
526 - }
527 - if !reflect.DeepEqual(ctx.IntSlice("s"), []int{10, 20}) {
528 - t.Errorf("short name not set")
529 - }
530 - },
531 - }).Run([]string{"run", "-s", "10", "-s", "20"})
532 -}
533 -
534 -func TestParseMultiIntSliceFromEnv(t *testing.T) {
535 - os.Clearenv()
536 - os.Setenv("APP_INTERVALS", "20,30,40")
537 -
538 - (&App{
539 - Flags: []Flag{
540 - IntSliceFlag{Name: "intervals, i", Value: &IntSlice{}, EnvVar: "APP_INTERVALS"},
541 - },
542 - Action: func(ctx *Context) {
543 - if !reflect.DeepEqual(ctx.IntSlice("intervals"), []int{20, 30, 40}) {
544 - t.Errorf("main name not set from env")
545 - }
546 - if !reflect.DeepEqual(ctx.IntSlice("i"), []int{20, 30, 40}) {
547 - t.Errorf("short name not set from env")
548 - }
549 - },
550 - }).Run([]string{"run"})
551 -}
552 -
553 -func TestParseMultiIntSliceFromEnvCascade(t *testing.T) {
554 - os.Clearenv()
555 - os.Setenv("APP_INTERVALS", "20,30,40")
556 -
557 - (&App{
558 - Flags: []Flag{
559 - IntSliceFlag{Name: "intervals, i", Value: &IntSlice{}, EnvVar: "COMPAT_INTERVALS,APP_INTERVALS"},
560 - },
561 - Action: func(ctx *Context) {
562 - if !reflect.DeepEqual(ctx.IntSlice("intervals"), []int{20, 30, 40}) {
563 - t.Errorf("main name not set from env")
564 - }
565 - if !reflect.DeepEqual(ctx.IntSlice("i"), []int{20, 30, 40}) {
566 - t.Errorf("short name not set from env")
567 - }
568 - },
569 - }).Run([]string{"run"})
570 -}
571 -
572 -func TestParseMultiFloat64(t *testing.T) {
573 - a := App{
574 - Flags: []Flag{
575 - Float64Flag{Name: "serve, s"},
576 - },
577 - Action: func(ctx *Context) {
578 - if ctx.Float64("serve") != 10.2 {
579 - t.Errorf("main name not set")
580 - }
581 - if ctx.Float64("s") != 10.2 {
582 - t.Errorf("short name not set")
583 - }
584 - },
585 - }
586 - a.Run([]string{"run", "-s", "10.2"})
587 -}
588 -
589 -func TestParseDestinationFloat64(t *testing.T) {
590 - var dest float64
591 - a := App{
592 - Flags: []Flag{
593 - Float64Flag{
594 - Name: "dest",
595 - Destination: &dest,
596 - },
597 - },
598 - Action: func(ctx *Context) {
599 - if dest != 10.2 {
600 - t.Errorf("expected destination Float64 10.2")
601 - }
602 - },
603 - }
604 - a.Run([]string{"run", "--dest", "10.2"})
605 -}
606 -
607 -func TestParseMultiFloat64FromEnv(t *testing.T) {
608 - os.Clearenv()
609 - os.Setenv("APP_TIMEOUT_SECONDS", "15.5")
610 - a := App{
611 - Flags: []Flag{
612 - Float64Flag{Name: "timeout, t", EnvVar: "APP_TIMEOUT_SECONDS"},
613 - },
614 - Action: func(ctx *Context) {
615 - if ctx.Float64("timeout") != 15.5 {
616 - t.Errorf("main name not set")
617 - }
618 - if ctx.Float64("t") != 15.5 {
619 - t.Errorf("short name not set")
620 - }
621 - },
622 - }
623 - a.Run([]string{"run"})
624 -}
625 -
626 -func TestParseMultiFloat64FromEnvCascade(t *testing.T) {
627 - os.Clearenv()
628 - os.Setenv("APP_TIMEOUT_SECONDS", "15.5")
629 - a := App{
630 - Flags: []Flag{
631 - Float64Flag{Name: "timeout, t", EnvVar: "COMPAT_TIMEOUT_SECONDS,APP_TIMEOUT_SECONDS"},
632 - },
633 - Action: func(ctx *Context) {
634 - if ctx.Float64("timeout") != 15.5 {
635 - t.Errorf("main name not set")
636 - }
637 - if ctx.Float64("t") != 15.5 {
638 - t.Errorf("short name not set")
639 - }
640 - },
641 - }
642 - a.Run([]string{"run"})
643 -}
644 -
645 -func TestParseMultiBool(t *testing.T) {
646 - a := App{
647 - Flags: []Flag{
648 - BoolFlag{Name: "serve, s"},
649 - },
650 - Action: func(ctx *Context) {
651 - if ctx.Bool("serve") != true {
652 - t.Errorf("main name not set")
653 - }
654 - if ctx.Bool("s") != true {
655 - t.Errorf("short name not set")
656 - }
657 - },
658 - }
659 - a.Run([]string{"run", "--serve"})
660 -}
661 -
662 -func TestParseDestinationBool(t *testing.T) {
663 - var dest bool
664 - a := App{
665 - Flags: []Flag{
666 - BoolFlag{
667 - Name: "dest",
668 - Destination: &dest,
669 - },
670 - },
671 - Action: func(ctx *Context) {
672 - if dest != true {
673 - t.Errorf("expected destination Bool true")
674 - }
675 - },
676 - }
677 - a.Run([]string{"run", "--dest"})
678 -}
679 -
680 -func TestParseMultiBoolFromEnv(t *testing.T) {
681 - os.Clearenv()
682 - os.Setenv("APP_DEBUG", "1")
683 - a := App{
684 - Flags: []Flag{
685 - BoolFlag{Name: "debug, d", EnvVar: "APP_DEBUG"},
686 - },
687 - Action: func(ctx *Context) {
688 - if ctx.Bool("debug") != true {
689 - t.Errorf("main name not set from env")
690 - }
691 - if ctx.Bool("d") != true {
692 - t.Errorf("short name not set from env")
693 - }
694 - },
695 - }
696 - a.Run([]string{"run"})
697 -}
698 -
699 -func TestParseMultiBoolFromEnvCascade(t *testing.T) {
700 - os.Clearenv()
701 - os.Setenv("APP_DEBUG", "1")
702 - a := App{
703 - Flags: []Flag{
704 - BoolFlag{Name: "debug, d", EnvVar: "COMPAT_DEBUG,APP_DEBUG"},
705 - },
706 - Action: func(ctx *Context) {
707 - if ctx.Bool("debug") != true {
708 - t.Errorf("main name not set from env")
709 - }
710 - if ctx.Bool("d") != true {
711 - t.Errorf("short name not set from env")
712 - }
713 - },
714 - }
715 - a.Run([]string{"run"})
716 -}
717 -
718 -func TestParseMultiBoolT(t *testing.T) {
719 - a := App{
720 - Flags: []Flag{
721 - BoolTFlag{Name: "serve, s"},
722 - },
723 - Action: func(ctx *Context) {
724 - if ctx.BoolT("serve") != true {
725 - t.Errorf("main name not set")
726 - }
727 - if ctx.BoolT("s") != true {
728 - t.Errorf("short name not set")
729 - }
730 - },
731 - }
732 - a.Run([]string{"run", "--serve"})
733 -}
734 -
735 -func TestParseDestinationBoolT(t *testing.T) {
736 - var dest bool
737 - a := App{
738 - Flags: []Flag{
739 - BoolTFlag{
740 - Name: "dest",
741 - Destination: &dest,
742 - },
743 - },
744 - Action: func(ctx *Context) {
745 - if dest != true {
746 - t.Errorf("expected destination BoolT true")
747 - }
748 - },
749 - }
750 - a.Run([]string{"run", "--dest"})
751 -}
752 -
753 -func TestParseMultiBoolTFromEnv(t *testing.T) {
754 - os.Clearenv()
755 - os.Setenv("APP_DEBUG", "0")
756 - a := App{
757 - Flags: []Flag{
758 - BoolTFlag{Name: "debug, d", EnvVar: "APP_DEBUG"},
759 - },
760 - Action: func(ctx *Context) {
761 - if ctx.BoolT("debug") != false {
762 - t.Errorf("main name not set from env")
763 - }
764 - if ctx.BoolT("d") != false {
765 - t.Errorf("short name not set from env")
766 - }
767 - },
768 - }
769 - a.Run([]string{"run"})
770 -}
771 -
772 -func TestParseMultiBoolTFromEnvCascade(t *testing.T) {
773 - os.Clearenv()
774 - os.Setenv("APP_DEBUG", "0")
775 - a := App{
776 - Flags: []Flag{
777 - BoolTFlag{Name: "debug, d", EnvVar: "COMPAT_DEBUG,APP_DEBUG"},
778 - },
779 - Action: func(ctx *Context) {
780 - if ctx.BoolT("debug") != false {
781 - t.Errorf("main name not set from env")
782 - }
783 - if ctx.BoolT("d") != false {
784 - t.Errorf("short name not set from env")
785 - }
786 - },
787 - }
788 - a.Run([]string{"run"})
789 -}
790 -
791 -type Parser [2]string
792 -
793 -func (p *Parser) Set(value string) error {
794 - parts := strings.Split(value, ",")
795 - if len(parts) != 2 {
796 - return fmt.Errorf("invalid format")
797 - }
798 -
799 - (*p)[0] = parts[0]
800 - (*p)[1] = parts[1]
801 -
802 - return nil
803 -}
804 -
805 -func (p *Parser) String() string {
806 - return fmt.Sprintf("%s,%s", p[0], p[1])
807 -}
808 -
809 -func TestParseGeneric(t *testing.T) {
810 - a := App{
811 - Flags: []Flag{
812 - GenericFlag{Name: "serve, s", Value: &Parser{}},
813 - },
814 - Action: func(ctx *Context) {
815 - if !reflect.DeepEqual(ctx.Generic("serve"), &Parser{"10", "20"}) {
816 - t.Errorf("main name not set")
817 - }
818 - if !reflect.DeepEqual(ctx.Generic("s"), &Parser{"10", "20"}) {
819 - t.Errorf("short name not set")
820 - }
821 - },
822 - }
823 - a.Run([]string{"run", "-s", "10,20"})
824 -}
825 -
826 -func TestParseGenericFromEnv(t *testing.T) {
827 - os.Clearenv()
828 - os.Setenv("APP_SERVE", "20,30")
829 - a := App{
830 - Flags: []Flag{
831 - GenericFlag{Name: "serve, s", Value: &Parser{}, EnvVar: "APP_SERVE"},
832 - },
833 - Action: func(ctx *Context) {
834 - if !reflect.DeepEqual(ctx.Generic("serve"), &Parser{"20", "30"}) {
835 - t.Errorf("main name not set from env")
836 - }
837 - if !reflect.DeepEqual(ctx.Generic("s"), &Parser{"20", "30"}) {
838 - t.Errorf("short name not set from env")
839 - }
840 - },
841 - }
842 - a.Run([]string{"run"})
843 -}
844 -
845 -func TestParseGenericFromEnvCascade(t *testing.T) {
846 - os.Clearenv()
847 - os.Setenv("APP_FOO", "99,2000")
848 - a := App{
849 - Flags: []Flag{
850 - GenericFlag{Name: "foos", Value: &Parser{}, EnvVar: "COMPAT_FOO,APP_FOO"},
851 - },
852 - Action: func(ctx *Context) {
853 - if !reflect.DeepEqual(ctx.Generic("foos"), &Parser{"99", "2000"}) {
854 - t.Errorf("value not set from env")
855 - }
856 - },
857 - }
858 - a.Run([]string{"run"})
859 -}
Godeps/_workspace/src/github.com/codegangsta/cli/help.go deleted
-248
@@ -1,248 +0,0 @@
1 -package cli
2 -
3 -import (
4 - "fmt"
5 - "io"
6 - "strings"
7 - "text/tabwriter"
8 - "text/template"
9 -)
10 -
11 -// The text template for the Default help topic.
12 -// cli.go uses text/template to render templates. You can
13 -// render custom help text by setting this variable.
14 -var AppHelpTemplate = `NAME:
15 - {{.Name}} - {{.Usage}}
16 -
17 -USAGE:
18 - {{if .UsageText}}{{.UsageText}}{{else}}{{.HelpName}} {{if .Flags}}[global options]{{end}}{{if .Commands}} command [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{end}}
19 - {{if .Version}}
20 -VERSION:
21 - {{.Version}}
22 - {{end}}{{if len .Authors}}
23 -AUTHOR(S):
24 - {{range .Authors}}{{ . }}{{end}}
25 - {{end}}{{if .Commands}}
26 -COMMANDS:
27 - {{range .Commands}}{{join .Names ", "}}{{ "\t" }}{{.Usage}}
28 - {{end}}{{end}}{{if .Flags}}
29 -GLOBAL OPTIONS:
30 - {{range .Flags}}{{.}}
31 - {{end}}{{end}}{{if .Copyright }}
32 -COPYRIGHT:
33 - {{.Copyright}}
34 - {{end}}
35 -`
36 -
37 -// The text template for the command help topic.
38 -// cli.go uses text/template to render templates. You can
39 -// render custom help text by setting this variable.
40 -var CommandHelpTemplate = `NAME:
41 - {{.HelpName}} - {{.Usage}}
42 -
43 -USAGE:
44 - {{.HelpName}}{{if .Flags}} [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{if .Description}}
45 -
46 -DESCRIPTION:
47 - {{.Description}}{{end}}{{if .Flags}}
48 -
49 -OPTIONS:
50 - {{range .Flags}}{{.}}
51 - {{end}}{{ end }}
52 -`
53 -
54 -// The text template for the subcommand help topic.
55 -// cli.go uses text/template to render templates. You can
56 -// render custom help text by setting this variable.
57 -var SubcommandHelpTemplate = `NAME:
58 - {{.HelpName}} - {{.Usage}}
59 -
60 -USAGE:
61 - {{.HelpName}} command{{if .Flags}} [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}
62 -
63 -COMMANDS:
64 - {{range .Commands}}{{join .Names ", "}}{{ "\t" }}{{.Usage}}
65 - {{end}}{{if .Flags}}
66 -OPTIONS:
67 - {{range .Flags}}{{.}}
68 - {{end}}{{end}}
69 -`
70 -
71 -var helpCommand = Command{
72 - Name: "help",
73 - Aliases: []string{"h"},
74 - Usage: "Shows a list of commands or help for one command",
75 - ArgsUsage: "[command]",
76 - Action: func(c *Context) {
77 - args := c.Args()
78 - if args.Present() {
79 - ShowCommandHelp(c, args.First())
80 - } else {
81 - ShowAppHelp(c)
82 - }
83 - },
84 -}
85 -
86 -var helpSubcommand = Command{
87 - Name: "help",
88 - Aliases: []string{"h"},
89 - Usage: "Shows a list of commands or help for one command",
90 - ArgsUsage: "[command]",
91 - Action: func(c *Context) {
92 - args := c.Args()
93 - if args.Present() {
94 - ShowCommandHelp(c, args.First())
95 - } else {
96 - ShowSubcommandHelp(c)
97 - }
98 - },
99 -}
100 -
101 -// Prints help for the App or Command
102 -type helpPrinter func(w io.Writer, templ string, data interface{})
103 -
104 -var HelpPrinter helpPrinter = printHelp
105 -
106 -// Prints version for the App
107 -var VersionPrinter = printVersion
108 -
109 -func ShowAppHelp(c *Context) {
110 - HelpPrinter(c.App.Writer, AppHelpTemplate, c.App)
111 -}
112 -
113 -// Prints the list of subcommands as the default app completion method
114 -func DefaultAppComplete(c *Context) {
115 - for _, command := range c.App.Commands {
116 - for _, name := range command.Names() {
117 - fmt.Fprintln(c.App.Writer, name)
118 - }
119 - }
120 -}
121 -
122 -// Prints help for the given command
123 -func ShowCommandHelp(ctx *Context, command string) {
124 - // show the subcommand help for a command with subcommands
125 - if command == "" {
126 - HelpPrinter(ctx.App.Writer, SubcommandHelpTemplate, ctx.App)
127 - return
128 - }
129 -
130 - for _, c := range ctx.App.Commands {
131 - if c.HasName(command) {
132 - HelpPrinter(ctx.App.Writer, CommandHelpTemplate, c)
133 - return
134 - }
135 - }
136 -
137 - if ctx.App.CommandNotFound != nil {
138 - ctx.App.CommandNotFound(ctx, command)
139 - } else {
140 - fmt.Fprintf(ctx.App.Writer, "No help topic for '%v'\n", command)
141 - }
142 -}
143 -
144 -// Prints help for the given subcommand
145 -func ShowSubcommandHelp(c *Context) {
146 - ShowCommandHelp(c, c.Command.Name)
147 -}
148 -
149 -// Prints the version number of the App
150 -func ShowVersion(c *Context) {
151 - VersionPrinter(c)
152 -}
153 -
154 -func printVersion(c *Context) {
155 - fmt.Fprintf(c.App.Writer, "%v version %v\n", c.App.Name, c.App.Version)
156 -}
157 -
158 -// Prints the lists of commands within a given context
159 -func ShowCompletions(c *Context) {
160 - a := c.App
161 - if a != nil && a.BashComplete != nil {
162 - a.BashComplete(c)
163 - }
164 -}
165 -
166 -// Prints the custom completions for a given command
167 -func ShowCommandCompletions(ctx *Context, command string) {
168 - c := ctx.App.Command(command)
169 - if c != nil && c.BashComplete != nil {
170 - c.BashComplete(ctx)
171 - }
172 -}
173 -
174 -func printHelp(out io.Writer, templ string, data interface{}) {
175 - funcMap := template.FuncMap{
176 - "join": strings.Join,
177 - }
178 -
179 - w := tabwriter.NewWriter(out, 0, 8, 1, '\t', 0)
180 - t := template.Must(template.New("help").Funcs(funcMap).Parse(templ))
181 - err := t.Execute(w, data)
182 - if err != nil {
183 - // If the writer is closed, t.Execute will fail, and there's nothing
184 - // we can do to recover. We could send this to os.Stderr if we need.
185 - return
186 - }
187 - w.Flush()
188 -}
189 -
190 -func checkVersion(c *Context) bool {
191 - found := false
192 - if VersionFlag.Name != "" {
193 - eachName(VersionFlag.Name, func(name string) {
194 - if c.GlobalBool(name) || c.Bool(name) {
195 - found = true
196 - }
197 - })
198 - }
199 - return found
200 -}
201 -
202 -func checkHelp(c *Context) bool {
203 - found := false
204 - if HelpFlag.Name != "" {
205 - eachName(HelpFlag.Name, func(name string) {
206 - if c.GlobalBool(name) || c.Bool(name) {
207 - found = true
208 - }
209 - })
210 - }
211 - return found
212 -}
213 -
214 -func checkCommandHelp(c *Context, name string) bool {
215 - if c.Bool("h") || c.Bool("help") {
216 - ShowCommandHelp(c, name)
217 - return true
218 - }
219 -
220 - return false
221 -}
222 -
223 -func checkSubcommandHelp(c *Context) bool {
224 - if c.GlobalBool("h") || c.GlobalBool("help") {
225 - ShowSubcommandHelp(c)
226 - return true
227 - }
228 -
229 - return false
230 -}
231 -
232 -func checkCompletions(c *Context) bool {
233 - if (c.GlobalBool(BashCompletionFlag.Name) || c.Bool(BashCompletionFlag.Name)) && c.App.EnableBashCompletion {
234 - ShowCompletions(c)
235 - return true
236 - }
237 -
238 - return false
239 -}
240 -
241 -func checkCommandCompletions(c *Context, name string) bool {
242 - if c.Bool(BashCompletionFlag.Name) && c.App.EnableBashCompletion {
243 - ShowCommandCompletions(c, name)
244 - return true
245 - }
246 -
247 - return false
248 -}
Godeps/_workspace/src/github.com/codegangsta/cli/help_test.go deleted
-94
@@ -1,94 +0,0 @@
1 -package cli
2 -
3 -import (
4 - "bytes"
5 - "testing"
6 -)
7 -
8 -func Test_ShowAppHelp_NoAuthor(t *testing.T) {
9 - output := new(bytes.Buffer)
10 - app := NewApp()
11 - app.Writer = output
12 -
13 - c := NewContext(app, nil, nil)
14 -
15 - ShowAppHelp(c)
16 -
17 - if bytes.Index(output.Bytes(), []byte("AUTHOR(S):")) != -1 {
18 - t.Errorf("expected\n%snot to include %s", output.String(), "AUTHOR(S):")
19 - }
20 -}
21 -
22 -func Test_ShowAppHelp_NoVersion(t *testing.T) {
23 - output := new(bytes.Buffer)
24 - app := NewApp()
25 - app.Writer = output
26 -
27 - app.Version = ""
28 -
29 - c := NewContext(app, nil, nil)
30 -
31 - ShowAppHelp(c)
32 -
33 - if bytes.Index(output.Bytes(), []byte("VERSION:")) != -1 {
34 - t.Errorf("expected\n%snot to include %s", output.String(), "VERSION:")
35 - }
36 -}
37 -
38 -func Test_Help_Custom_Flags(t *testing.T) {
39 - oldFlag := HelpFlag
40 - defer func() {
41 - HelpFlag = oldFlag
42 - }()
43 -
44 - HelpFlag = BoolFlag{
45 - Name: "help, x",
46 - Usage: "show help",
47 - }
48 -
49 - app := App{
50 - Flags: []Flag{
51 - BoolFlag{Name: "foo, h"},
52 - },
53 - Action: func(ctx *Context) {
54 - if ctx.Bool("h") != true {
55 - t.Errorf("custom help flag not set")
56 - }
57 - },
58 - }
59 - output := new(bytes.Buffer)
60 - app.Writer = output
61 - app.Run([]string{"test", "-h"})
62 - if output.Len() > 0 {
63 - t.Errorf("unexpected output: %s", output.String())
64 - }
65 -}
66 -
67 -func Test_Version_Custom_Flags(t *testing.T) {
68 - oldFlag := VersionFlag
69 - defer func() {
70 - VersionFlag = oldFlag
71 - }()
72 -
73 - VersionFlag = BoolFlag{
74 - Name: "version, V",
75 - Usage: "show version",
76 - }
77 -
78 - app := App{
79 - Flags: []Flag{
80 - BoolFlag{Name: "foo, v"},
81 - },
82 - Action: func(ctx *Context) {
83 - if ctx.Bool("v") != true {
84 - t.Errorf("custom version flag not set")
85 - }
86 - },
87 - }
88 - output := new(bytes.Buffer)
89 - app.Writer = output
90 - app.Run([]string{"test", "-v"})
91 - if output.Len() > 0 {
92 - t.Errorf("unexpected output: %s", output.String())
93 - }
94 -}
Godeps/_workspace/src/github.com/codegangsta/cli/helpers_test.go deleted
-19
@@ -1,19 +0,0 @@
1 -package cli
2 -
3 -import (
4 - "reflect"
5 - "testing"
6 -)
7 -
8 -/* Test Helpers */
9 -func expect(t *testing.T, a interface{}, b interface{}) {
10 - if !reflect.DeepEqual(a, b) {
11 - t.Errorf("Expected %v (type %v) - Got %v (type %v)", b, reflect.TypeOf(b), a, reflect.TypeOf(a))
12 - }
13 -}
14 -
15 -func refute(t *testing.T, a interface{}, b interface{}) {
16 - if reflect.DeepEqual(a, b) {
17 - t.Errorf("Did not expect %v (type %v) - Got %v (type %v)", b, reflect.TypeOf(b), a, reflect.TypeOf(a))
18 - }
19 -}
cmd/ipfs/daemon.go
+4 -4
@@ -12,9 +12,9 @@ import (
12 "sync"
13
14 _ "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/codahale/metrics/runtime"
15 - "gx/ipfs/QmTrxSBY8Wqd5aBB4MeizeSzS5xFbK8dQBrYaMsiGnCBhb/go-multiaddr-net"
15 + "gx/ipfs/QmUBa4w6CbHJUMeGJPDiMEDWsM93xToK1fTnFXnrC8Hksw/go-multiaddr-net"
16
17 - ma "gx/ipfs/QmcobAGsCjYt5DXoq9et9L8yR8er7o7Cu3DTvpaq12jYSz/go-multiaddr"
17 + ma "gx/ipfs/QmYzDkkgAEmrcNzFCiYo6L1dTX4EAG1gZkbtdbd9trL4vd/go-multiaddr"
18
19 cmds "github.com/ipfs/go-ipfs/commands"
20 "github.com/ipfs/go-ipfs/core"
@@ -24,9 +24,9 @@ import (
24 "github.com/ipfs/go-ipfs/core/corerouting"
25 nodeMount "github.com/ipfs/go-ipfs/fuse/node"
26 fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo"
27 - conn "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/net/conn"
27 util "gx/ipfs/QmZNVWh8LLjAavuQ2JXuFmuYH3C11xo988vSgp7UQrTRj1/go-ipfs-util"
29 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
28 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
29 + conn "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/net/conn"
30 prometheus "gx/ipfs/QmdhsRK1EK2fvAz2i2SH5DEfkL6seDuyMYEsxKa9Braim3/client_golang/prometheus"
31 )
32
cmd/ipfs/main.go
+2 -2
@@ -17,8 +17,8 @@ import (
17 "syscall"
18 "time"
19
20 - manet "gx/ipfs/QmTrxSBY8Wqd5aBB4MeizeSzS5xFbK8dQBrYaMsiGnCBhb/go-multiaddr-net"
21 - ma "gx/ipfs/QmcobAGsCjYt5DXoq9et9L8yR8er7o7Cu3DTvpaq12jYSz/go-multiaddr"
20 + manet "gx/ipfs/QmUBa4w6CbHJUMeGJPDiMEDWsM93xToK1fTnFXnrC8Hksw/go-multiaddr-net"
21 + ma "gx/ipfs/QmYzDkkgAEmrcNzFCiYo6L1dTX4EAG1gZkbtdbd9trL4vd/go-multiaddr"
22
23 u "gx/ipfs/QmZNVWh8LLjAavuQ2JXuFmuYH3C11xo988vSgp7UQrTRj1/go-ipfs-util"
24 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
cmd/seccat/seccat.go
+2 -2
@@ -18,9 +18,9 @@ import (
18 "os/signal"
19 "syscall"
20
21 - secio "gx/ipfs/QmPKuU1ohMDaJRJHmatXewCqjZp5wKrD3CK6m9TnCK6XBe/go-libp2p-secio"
21 + secio "gx/ipfs/QmPDQHJHvzAp9Tver9VAoqzuzcS3uEjPYLYp2CMh89h5fC/go-libp2p-secio"
22 ci "gx/ipfs/QmUEUu1CM8bxBJxc3ZLojAi8evhTr4byQogWstABet79oY/go-libp2p-crypto"
23 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
23 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
24 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
25 logging "gx/ipfs/QmaDNZ4QMdBdku1YZWBysufYyoQt1negQGNav6PLYarbY8/go-log"
26 )
core/bootstrap.go
+3 -3
@@ -11,9 +11,9 @@ import (
11 config "github.com/ipfs/go-ipfs/repo/config"
12 lgbl "github.com/ipfs/go-ipfs/thirdparty/loggables"
13 math2 "github.com/ipfs/go-ipfs/thirdparty/math2"
14 - host "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/host"
15 - inet "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/net"
16 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
14 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
15 + host "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/host"
16 + inet "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/net"
17
18 goprocess "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess"
19 procctx "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess/context"
core/bootstrap_test.go
+1 -1
@@ -6,7 +6,7 @@ import (
6
7 config "github.com/ipfs/go-ipfs/repo/config"
8 testutil "github.com/ipfs/go-ipfs/thirdparty/testutil"
9 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
9 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
10 )
11
12 func TestSubsetWhenMaxIsGreaterThanLengthOfSlice(t *testing.T) {
core/builder.go
+1 -1
@@ -18,7 +18,7 @@ import (
18 cfg "github.com/ipfs/go-ipfs/repo/config"
19 goprocessctx "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess/context"
20 ci "gx/ipfs/QmUEUu1CM8bxBJxc3ZLojAi8evhTr4byQogWstABet79oY/go-libp2p-crypto"
21 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
21 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
22 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
23 )
24
core/commands/bitswap.go
+1 -1
@@ -11,7 +11,7 @@ import (
11 cmds "github.com/ipfs/go-ipfs/commands"
12 bitswap "github.com/ipfs/go-ipfs/exchange/bitswap"
13 u "gx/ipfs/QmZNVWh8LLjAavuQ2JXuFmuYH3C11xo988vSgp7UQrTRj1/go-ipfs-util"
14 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
14 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
15 )
16
17 var BitswapCmd = &cmds.Command{
core/commands/dht.go
+1 -1
@@ -13,7 +13,7 @@ import (
13 path "github.com/ipfs/go-ipfs/path"
14 ipdht "github.com/ipfs/go-ipfs/routing/dht"
15 u "gx/ipfs/QmZNVWh8LLjAavuQ2JXuFmuYH3C11xo988vSgp7UQrTRj1/go-ipfs-util"
16 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
16 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
17 )
18
19 var ErrNotDHT = errors.New("routing service is not a DHT")
core/commands/id.go
+2 -2
@@ -14,9 +14,9 @@ import (
14 core "github.com/ipfs/go-ipfs/core"
15 kb "github.com/ipfs/go-ipfs/routing/kbucket"
16 ic "gx/ipfs/QmUEUu1CM8bxBJxc3ZLojAi8evhTr4byQogWstABet79oY/go-libp2p-crypto"
17 - identify "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/protocol/identify"
17 u "gx/ipfs/QmZNVWh8LLjAavuQ2JXuFmuYH3C11xo988vSgp7UQrTRj1/go-ipfs-util"
19 - "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
18 + "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
19 + identify "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/protocol/identify"
20 )
21
22 const offlineIdErrorMessage = `'ipfs id' currently cannot query information on remote
core/commands/ping.go
+2 -2
@@ -11,10 +11,10 @@ import (
11 cmds "github.com/ipfs/go-ipfs/commands"
12 core "github.com/ipfs/go-ipfs/core"
13 u "gx/ipfs/QmZNVWh8LLjAavuQ2JXuFmuYH3C11xo988vSgp7UQrTRj1/go-ipfs-util"
14 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
14 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
15
16 + ma "gx/ipfs/QmYzDkkgAEmrcNzFCiYo6L1dTX4EAG1gZkbtdbd9trL4vd/go-multiaddr"
17 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
17 - ma "gx/ipfs/QmcobAGsCjYt5DXoq9et9L8yR8er7o7Cu3DTvpaq12jYSz/go-multiaddr"
18 )
19
20 const kPingTimeout = 10 * time.Second
core/commands/stat.go
+3 -3
@@ -10,10 +10,10 @@ import (
10 humanize "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/dustin/go-humanize"
11
12 cmds "github.com/ipfs/go-ipfs/commands"
13 - metrics "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/metrics"
14 - protocol "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/protocol"
13 u "gx/ipfs/QmZNVWh8LLjAavuQ2JXuFmuYH3C11xo988vSgp7UQrTRj1/go-ipfs-util"
16 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
14 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
15 + metrics "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/metrics"
16 + protocol "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/protocol"
17 )
18
19 var StatsCmd = &cmds.Command{
core/commands/swarm.go
+4 -4
@@ -10,11 +10,11 @@ import (
10
11 cmds "github.com/ipfs/go-ipfs/commands"
12 iaddr "github.com/ipfs/go-ipfs/thirdparty/ipfsaddr"
13 - swarm "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/net/swarm"
14 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
13 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
14 + swarm "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/net/swarm"
15
16 - ma "gx/ipfs/QmcobAGsCjYt5DXoq9et9L8yR8er7o7Cu3DTvpaq12jYSz/go-multiaddr"
17 - mafilter "gx/ipfs/Qme8dipKnZAChkp5Kfgj2MYYyBbzjqqPXmxQx3g9v3MoxP/multiaddr-filter"
16 + mafilter "gx/ipfs/QmUaRHbB7pUwj5mS9BS4CMvBiW48MpaH2wbGxeWfFhhHxK/multiaddr-filter"
17 + ma "gx/ipfs/QmYzDkkgAEmrcNzFCiYo6L1dTX4EAG1gZkbtdbd9trL4vd/go-multiaddr"
18 )
19
20 type stringList struct {
core/commands/sysdiag.go
+1 -1
@@ -9,7 +9,7 @@ import (
9 config "github.com/ipfs/go-ipfs/repo/config"
10
11 sysi "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/whyrusleeping/go-sysinfo"
12 - manet "gx/ipfs/QmTrxSBY8Wqd5aBB4MeizeSzS5xFbK8dQBrYaMsiGnCBhb/go-multiaddr-net"
12 + manet "gx/ipfs/QmUBa4w6CbHJUMeGJPDiMEDWsM93xToK1fTnFXnrC8Hksw/go-multiaddr-net"
13 )
14
15 var sysDiagCmd = &cmds.Command{
core/core.go
+11 -11
@@ -21,19 +21,19 @@ import (
21 goprocess "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess"
22 b58 "gx/ipfs/QmT8rehPR3F6bmwL6zjUN8XpiDBFFpMP2myPdC6ApsWfJf/go-base58"
23 ic "gx/ipfs/QmUEUu1CM8bxBJxc3ZLojAi8evhTr4byQogWstABet79oY/go-libp2p-crypto"
24 - discovery "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/discovery"
25 - p2phost "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/host"
26 - p2pbhost "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/host/basic"
27 - rhost "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/host/routed"
28 - metrics "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/metrics"
29 - swarm "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/net/swarm"
30 - addrutil "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/net/swarm/addr"
31 - ping "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/protocol/ping"
32 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
24 + mamask "gx/ipfs/QmUaRHbB7pUwj5mS9BS4CMvBiW48MpaH2wbGxeWfFhhHxK/multiaddr-filter"
25 + ma "gx/ipfs/QmYzDkkgAEmrcNzFCiYo6L1dTX4EAG1gZkbtdbd9trL4vd/go-multiaddr"
26 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
27 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
28 logging "gx/ipfs/QmaDNZ4QMdBdku1YZWBysufYyoQt1negQGNav6PLYarbY8/go-log"
35 - ma "gx/ipfs/QmcobAGsCjYt5DXoq9et9L8yR8er7o7Cu3DTvpaq12jYSz/go-multiaddr"
36 - mamask "gx/ipfs/Qme8dipKnZAChkp5Kfgj2MYYyBbzjqqPXmxQx3g9v3MoxP/multiaddr-filter"
29 + discovery "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/discovery"
30 + p2phost "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/host"
31 + p2pbhost "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/host/basic"
32 + rhost "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/host/routed"
33 + metrics "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/metrics"
34 + swarm "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/net/swarm"
35 + addrutil "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/net/swarm/addr"
36 + ping "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/protocol/ping"
37
38 routing "github.com/ipfs/go-ipfs/routing"
39 dht "github.com/ipfs/go-ipfs/routing/dht"
core/corehttp/corehttp.go
+2 -2
@@ -12,9 +12,9 @@ import (
12
13 core "github.com/ipfs/go-ipfs/core"
14 "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess"
15 - manet "gx/ipfs/QmTrxSBY8Wqd5aBB4MeizeSzS5xFbK8dQBrYaMsiGnCBhb/go-multiaddr-net"
15 + manet "gx/ipfs/QmUBa4w6CbHJUMeGJPDiMEDWsM93xToK1fTnFXnrC8Hksw/go-multiaddr-net"
16 + ma "gx/ipfs/QmYzDkkgAEmrcNzFCiYo6L1dTX4EAG1gZkbtdbd9trL4vd/go-multiaddr"
17 logging "gx/ipfs/QmaDNZ4QMdBdku1YZWBysufYyoQt1negQGNav6PLYarbY8/go-log"
17 - ma "gx/ipfs/QmcobAGsCjYt5DXoq9et9L8yR8er7o7Cu3DTvpaq12jYSz/go-multiaddr"
18 )
19
20 var log = logging.Logger("core/server")
core/corehttp/gateway.go
+1 -1
@@ -8,7 +8,7 @@ import (
8
9 core "github.com/ipfs/go-ipfs/core"
10 config "github.com/ipfs/go-ipfs/repo/config"
11 - id "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/protocol/identify"
11 + id "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/protocol/identify"
12 )
13
14 // Gateway should be instantiated using NewGateway
core/corehttp/gateway_test.go
+1 -1
@@ -17,8 +17,8 @@ import (
17 config "github.com/ipfs/go-ipfs/repo/config"
18 testutil "github.com/ipfs/go-ipfs/thirdparty/testutil"
19 ci "gx/ipfs/QmUEUu1CM8bxBJxc3ZLojAi8evhTr4byQogWstABet79oY/go-libp2p-crypto"
20 - id "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/protocol/identify"
20 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
21 + id "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/protocol/identify"
22 )
23
24 type mockNamesys map[string]path.Path
core/corehttp/metrics_test.go
+3 -3
@@ -5,10 +5,10 @@ import (
5 "time"
6
7 core "github.com/ipfs/go-ipfs/core"
8 - bhost "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/host/basic"
9 - inet "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/net"
10 - testutil "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/test/util"
8 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
9 + bhost "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/host/basic"
10 + inet "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/net"
11 + testutil "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/test/util"
12 )
13
14 // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect
core/corenet/net.go
+3 -3
@@ -4,10 +4,10 @@ import (
4 "time"
5
6 core "github.com/ipfs/go-ipfs/core"
7 - net "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/net"
8 - pro "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/protocol"
9 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
7 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
8 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
9 + net "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/net"
10 + pro "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/protocol"
11 )
12
13 type ipfsListener struct {
core/corerouting/core.go
+2 -2
@@ -9,9 +9,9 @@ import (
9 routing "github.com/ipfs/go-ipfs/routing"
10 supernode "github.com/ipfs/go-ipfs/routing/supernode"
11 gcproxy "github.com/ipfs/go-ipfs/routing/supernode/proxy"
12 - "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/host"
13 - "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
12 + "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
13 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
14 + "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/host"
15 )
16
17 // NB: DHT option is included in the core to avoid 1) because it's a sane
core/mock/mock.go
+4 -4
@@ -13,10 +13,10 @@ import (
13 config "github.com/ipfs/go-ipfs/repo/config"
14 ds2 "github.com/ipfs/go-ipfs/thirdparty/datastore2"
15 testutil "github.com/ipfs/go-ipfs/thirdparty/testutil"
16 - host "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/host"
17 - metrics "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/metrics"
18 - mocknet "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/net/mock"
19 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
16 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
17 + host "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/host"
18 + metrics "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/metrics"
19 + mocknet "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/net/mock"
20 )
21
22 // NewMockNode constructs an IpfsNode for use in tests.
diagnostics/diag.go
+4 -4
@@ -13,14 +13,14 @@ import (
13
14 ctxio "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-context/io"
15 pb "github.com/ipfs/go-ipfs/diagnostics/pb"
16 - host "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/host"
17 - inet "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/net"
18 - protocol "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/protocol"
16 ggio "gx/ipfs/QmZ4Qi3GaRbjcx28Sme5eMH7RQjGkt8wHxt2a65oLaeFEV/gogo-protobuf/io"
17 proto "gx/ipfs/QmZ4Qi3GaRbjcx28Sme5eMH7RQjGkt8wHxt2a65oLaeFEV/gogo-protobuf/proto"
21 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
18 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
19 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
20 logging "gx/ipfs/QmaDNZ4QMdBdku1YZWBysufYyoQt1negQGNav6PLYarbY8/go-log"
21 + host "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/host"
22 + inet "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/net"
23 + protocol "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/protocol"
24 )
25
26 var log = logging.Logger("diagnostics")
diagnostics/vis.go
+1 -1
@@ -6,7 +6,7 @@ import (
6 "io"
7
8 rtable "github.com/ipfs/go-ipfs/routing/kbucket"
9 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
9 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
10 )
11
12 type node struct {
exchange/bitswap/bitswap.go
+1 -1
@@ -10,7 +10,7 @@ import (
10
11 process "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess"
12 procctx "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess/context"
13 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
13 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
14 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
15 logging "gx/ipfs/QmaDNZ4QMdBdku1YZWBysufYyoQt1negQGNav6PLYarbY8/go-log"
16
exchange/bitswap/bitswap_test.go
+1 -1
@@ -16,7 +16,7 @@ import (
16 tn "github.com/ipfs/go-ipfs/exchange/bitswap/testnet"
17 mockrouting "github.com/ipfs/go-ipfs/routing/mock"
18 delay "github.com/ipfs/go-ipfs/thirdparty/delay"
19 - p2ptestutil "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/test/util"
19 + p2ptestutil "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/test/util"
20 )
21
22 // FIXME the tests are really sensitive to the network delay. fix them to work
exchange/bitswap/decision/bench_test.go
+1 -1
@@ -7,7 +7,7 @@ import (
7 key "github.com/ipfs/go-ipfs/blocks/key"
8 "github.com/ipfs/go-ipfs/exchange/bitswap/wantlist"
9 "github.com/ipfs/go-ipfs/thirdparty/testutil"
10 - "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
10 + "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
11 )
12
13 // FWIW: At the time of this commit, including a timestamp in task increases
exchange/bitswap/decision/engine.go
+1 -1
@@ -8,7 +8,7 @@ import (
8 bstore "github.com/ipfs/go-ipfs/blocks/blockstore"
9 bsmsg "github.com/ipfs/go-ipfs/exchange/bitswap/message"
10 wl "github.com/ipfs/go-ipfs/exchange/bitswap/wantlist"
11 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
11 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
12 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
13 logging "gx/ipfs/QmaDNZ4QMdBdku1YZWBysufYyoQt1negQGNav6PLYarbY8/go-log"
14 )
exchange/bitswap/decision/engine_test.go
+1 -1
@@ -14,7 +14,7 @@ import (
14 blockstore "github.com/ipfs/go-ipfs/blocks/blockstore"
15 message "github.com/ipfs/go-ipfs/exchange/bitswap/message"
16 testutil "github.com/ipfs/go-ipfs/thirdparty/testutil"
17 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
17 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
18 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
19 )
20
exchange/bitswap/decision/ledger.go
+1 -1
@@ -5,7 +5,7 @@ import (
5
6 key "github.com/ipfs/go-ipfs/blocks/key"
7 wl "github.com/ipfs/go-ipfs/exchange/bitswap/wantlist"
8 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
8 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
9 )
10
11 // keySet is just a convenient alias for maps of keys, where we only care
exchange/bitswap/decision/peer_request_queue.go
+1 -1
@@ -7,7 +7,7 @@ import (
7 key "github.com/ipfs/go-ipfs/blocks/key"
8 wantlist "github.com/ipfs/go-ipfs/exchange/bitswap/wantlist"
9 pq "github.com/ipfs/go-ipfs/thirdparty/pq"
10 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
10 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
11 )
12
13 type peerRequestQueue interface {
exchange/bitswap/message/message.go
+1 -1
@@ -7,7 +7,7 @@ import (
7 key "github.com/ipfs/go-ipfs/blocks/key"
8 pb "github.com/ipfs/go-ipfs/exchange/bitswap/message/pb"
9 wantlist "github.com/ipfs/go-ipfs/exchange/bitswap/wantlist"
10 - inet "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/net"
10 + inet "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/net"
11
12 ggio "gx/ipfs/QmZ4Qi3GaRbjcx28Sme5eMH7RQjGkt8wHxt2a65oLaeFEV/gogo-protobuf/io"
13 proto "gx/ipfs/QmZ4Qi3GaRbjcx28Sme5eMH7RQjGkt8wHxt2a65oLaeFEV/gogo-protobuf/proto"
exchange/bitswap/network/interface.go
+2 -2
@@ -3,9 +3,9 @@ package network
3 import (
4 key "github.com/ipfs/go-ipfs/blocks/key"
5 bsmsg "github.com/ipfs/go-ipfs/exchange/bitswap/message"
6 - protocol "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/protocol"
7 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
6 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
7 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
8 + protocol "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/protocol"
9 )
10
11 var ProtocolBitswap protocol.ID = "/ipfs/bitswap"
exchange/bitswap/network/ipfs_impl.go
+4 -4
@@ -4,12 +4,12 @@ import (
4 key "github.com/ipfs/go-ipfs/blocks/key"
5 bsmsg "github.com/ipfs/go-ipfs/exchange/bitswap/message"
6 routing "github.com/ipfs/go-ipfs/routing"
7 - host "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/host"
8 - inet "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/net"
9 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
7 + ma "gx/ipfs/QmYzDkkgAEmrcNzFCiYo6L1dTX4EAG1gZkbtdbd9trL4vd/go-multiaddr"
8 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
9 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
10 logging "gx/ipfs/QmaDNZ4QMdBdku1YZWBysufYyoQt1negQGNav6PLYarbY8/go-log"
12 - ma "gx/ipfs/QmcobAGsCjYt5DXoq9et9L8yR8er7o7Cu3DTvpaq12jYSz/go-multiaddr"
11 + host "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/host"
12 + inet "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/net"
13 )
14
15 var log = logging.Logger("bitswap_network")
exchange/bitswap/testnet/interface.go
+1 -1
@@ -3,7 +3,7 @@ package bitswap
3 import (
4 bsnet "github.com/ipfs/go-ipfs/exchange/bitswap/network"
5 "github.com/ipfs/go-ipfs/thirdparty/testutil"
6 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
6 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
7 )
8
9 type Network interface {
exchange/bitswap/testnet/network_test.go
+1 -1
@@ -10,7 +10,7 @@ import (
10 mockrouting "github.com/ipfs/go-ipfs/routing/mock"
11 delay "github.com/ipfs/go-ipfs/thirdparty/delay"
12 testutil "github.com/ipfs/go-ipfs/thirdparty/testutil"
13 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
13 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
14 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
15 )
16
exchange/bitswap/testnet/peernet.go
+2 -2
@@ -5,9 +5,9 @@ import (
5 bsnet "github.com/ipfs/go-ipfs/exchange/bitswap/network"
6 mockrouting "github.com/ipfs/go-ipfs/routing/mock"
7 testutil "github.com/ipfs/go-ipfs/thirdparty/testutil"
8 - mockpeernet "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/net/mock"
9 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
8 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
9 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
10 + mockpeernet "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/net/mock"
11 )
12
13 type peernet struct {
exchange/bitswap/testnet/virtual.go
+1 -1
@@ -10,7 +10,7 @@ import (
10 mockrouting "github.com/ipfs/go-ipfs/routing/mock"
11 delay "github.com/ipfs/go-ipfs/thirdparty/delay"
12 testutil "github.com/ipfs/go-ipfs/thirdparty/testutil"
13 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
13 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
14 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
15 )
16
exchange/bitswap/testutils.go
+2 -2
@@ -10,9 +10,9 @@ import (
10 datastore2 "github.com/ipfs/go-ipfs/thirdparty/datastore2"
11 delay "github.com/ipfs/go-ipfs/thirdparty/delay"
12 testutil "github.com/ipfs/go-ipfs/thirdparty/testutil"
13 - p2ptestutil "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/test/util"
14 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
13 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
14 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
15 + p2ptestutil "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/test/util"
16 )
17
18 // WARNING: this uses RandTestBogusIdentity DO NOT USE for NON TESTS!
exchange/bitswap/wantmanager.go
+1 -1
@@ -9,7 +9,7 @@ import (
9 bsmsg "github.com/ipfs/go-ipfs/exchange/bitswap/message"
10 bsnet "github.com/ipfs/go-ipfs/exchange/bitswap/network"
11 wantlist "github.com/ipfs/go-ipfs/exchange/bitswap/wantlist"
12 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
12 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
13 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
14 )
15
exchange/bitswap/workers.go
+1 -1
@@ -10,7 +10,7 @@ import (
10
11 key "github.com/ipfs/go-ipfs/blocks/key"
12 wantlist "github.com/ipfs/go-ipfs/exchange/bitswap/wantlist"
13 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
13 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
14 logging "gx/ipfs/QmaDNZ4QMdBdku1YZWBysufYyoQt1negQGNav6PLYarbY8/go-log"
15 )
16
namesys/publisher.go
+1 -1
@@ -21,7 +21,7 @@ import (
21 ft "github.com/ipfs/go-ipfs/unixfs"
22 ci "gx/ipfs/QmUEUu1CM8bxBJxc3ZLojAi8evhTr4byQogWstABet79oY/go-libp2p-crypto"
23 u "gx/ipfs/QmZNVWh8LLjAavuQ2JXuFmuYH3C11xo988vSgp7UQrTRj1/go-ipfs-util"
24 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
24 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
25 )
26
27 // ErrExpiredRecord should be returned when an ipns record is
namesys/republisher/repub.go
+1 -1
@@ -11,7 +11,7 @@ import (
11 path "github.com/ipfs/go-ipfs/path"
12 "github.com/ipfs/go-ipfs/routing"
13 dhtpb "github.com/ipfs/go-ipfs/routing/dht/pb"
14 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
14 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
15
16 ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
17 goprocess "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess"
namesys/republisher/repub_test.go
+2 -2
@@ -13,8 +13,8 @@ import (
13 namesys "github.com/ipfs/go-ipfs/namesys"
14 . "github.com/ipfs/go-ipfs/namesys/republisher"
15 path "github.com/ipfs/go-ipfs/path"
16 - mocknet "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/net/mock"
17 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
16 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
17 + mocknet "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/net/mock"
18 )
19
20 func TestRepublish(t *testing.T) {
namesys/resolve_test.go
+1 -1
@@ -12,7 +12,7 @@ import (
12 mockrouting "github.com/ipfs/go-ipfs/routing/mock"
13 testutil "github.com/ipfs/go-ipfs/thirdparty/testutil"
14 u "gx/ipfs/QmZNVWh8LLjAavuQ2JXuFmuYH3C11xo988vSgp7UQrTRj1/go-ipfs-util"
15 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
15 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
16 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
17 )
18
notifications/query.go
+1 -1
@@ -3,7 +3,7 @@ package notifications
3 import (
4 "encoding/json"
5
6 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
6 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
7 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
8 )
9
package.json
+8 -8
@@ -13,15 +13,15 @@
13 "version": "1.1.0"
14 },
15 {
16 - "hash": "QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5",
16 + "hash": "QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8",
17 "name": "go-libp2p",
18 - "version": "2.0.3"
18 + "version": "3.1.0"
19 },
20 {
21 "author": "whyrusleeping",
22 - "hash": "QmPKuU1ohMDaJRJHmatXewCqjZp5wKrD3CK6m9TnCK6XBe",
22 + "hash": "QmPDQHJHvzAp9Tver9VAoqzuzcS3uEjPYLYp2CMh89h5fC",
23 "name": "go-libp2p-secio",
24 - "version": "1.0.1"
24 + "version": "1.0.2"
25 },
26 {
27 "author": "whyrusleeping",
@@ -31,9 +31,9 @@
31 },
32 {
33 "author": "whyrusleeping",
34 - "hash": "QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt",
34 + "hash": "QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7",
35 "name": "go-libp2p-peer",
36 - "version": "1.0.2"
36 + "version": "1.0.4"
37 },
38 {
39 "hash": "QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt",
@@ -61,9 +61,9 @@
61 "version": "0.0.0"
62 },
63 {
64 - "hash": "QmSx5xkktduyo1hBL7kZxdiZq1P9TrgeGkNW8qtoY14bSk",
64 + "hash": "QmaMGvaTmd613tWZuVjw3ohvdz1Gh1CBJ2fgb96eyp4EfE",
65 "name": "iptb",
66 - "version": "0.0.0"
66 + "version": "1.0.0"
67 },
68 {
69 "hash": "QmYf7ng2hG5XBtJA3tN34DQ2GUN5HNksEw1rLDkmr6vGku",
repo/config/init.go
+1 -1
@@ -7,7 +7,7 @@ import (
7 "io"
8
9 ci "gx/ipfs/QmUEUu1CM8bxBJxc3ZLojAi8evhTr4byQogWstABet79oY/go-libp2p-crypto"
10 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
10 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
11 )
12
13 func Init(out io.Writer, nBitsForKeypair int) (*Config, error) {
routing/dht/dht.go
+3 -3
@@ -15,10 +15,10 @@ import (
15 kb "github.com/ipfs/go-ipfs/routing/kbucket"
16 record "github.com/ipfs/go-ipfs/routing/record"
17 ci "gx/ipfs/QmUEUu1CM8bxBJxc3ZLojAi8evhTr4byQogWstABet79oY/go-libp2p-crypto"
18 - host "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/host"
19 - protocol "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/protocol"
20 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
18 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
19 logging "gx/ipfs/QmaDNZ4QMdBdku1YZWBysufYyoQt1negQGNav6PLYarbY8/go-log"
20 + host "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/host"
21 + protocol "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/protocol"
22
23 ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
24 goprocess "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess"
routing/dht/dht_bootstrap.go
+1 -1
@@ -10,7 +10,7 @@ import (
10
11 routing "github.com/ipfs/go-ipfs/routing"
12 u "gx/ipfs/QmZNVWh8LLjAavuQ2JXuFmuYH3C11xo988vSgp7UQrTRj1/go-ipfs-util"
13 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
13 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
14
15 goprocess "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess"
16 periodicproc "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess/periodic"
routing/dht/dht_net.go
+2 -2
@@ -6,10 +6,10 @@ import (
6
7 ctxio "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-context/io"
8 pb "github.com/ipfs/go-ipfs/routing/dht/pb"
9 - inet "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/net"
9 ggio "gx/ipfs/QmZ4Qi3GaRbjcx28Sme5eMH7RQjGkt8wHxt2a65oLaeFEV/gogo-protobuf/io"
11 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
10 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
11 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
12 + inet "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/net"
13 )
14
15 // handleNewStream implements the inet.StreamHandler
routing/dht/dht_test.go
+3 -3
@@ -11,15 +11,15 @@ import (
11
12 ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
13 dssync "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/sync"
14 + ma "gx/ipfs/QmYzDkkgAEmrcNzFCiYo6L1dTX4EAG1gZkbtdbd9trL4vd/go-multiaddr"
15 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
15 - ma "gx/ipfs/QmcobAGsCjYt5DXoq9et9L8yR8er7o7Cu3DTvpaq12jYSz/go-multiaddr"
16
17 key "github.com/ipfs/go-ipfs/blocks/key"
18 routing "github.com/ipfs/go-ipfs/routing"
19 record "github.com/ipfs/go-ipfs/routing/record"
20 - netutil "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/test/util"
20 u "gx/ipfs/QmZNVWh8LLjAavuQ2JXuFmuYH3C11xo988vSgp7UQrTRj1/go-ipfs-util"
22 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
21 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
22 + netutil "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/test/util"
23
24 ci "github.com/ipfs/go-ipfs/thirdparty/testutil/ci"
25 travisci "github.com/ipfs/go-ipfs/thirdparty/testutil/ci/travis"
routing/dht/diag.go
+1 -1
@@ -4,7 +4,7 @@ import (
4 "encoding/json"
5 "time"
6
7 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
7 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
8 )
9
10 type connDiagInfo struct {
routing/dht/ext_test.go
+3 -3
@@ -16,10 +16,10 @@ import (
16 routing "github.com/ipfs/go-ipfs/routing"
17 pb "github.com/ipfs/go-ipfs/routing/dht/pb"
18 record "github.com/ipfs/go-ipfs/routing/record"
19 - inet "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/net"
20 - mocknet "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/net/mock"
19 u "gx/ipfs/QmZNVWh8LLjAavuQ2JXuFmuYH3C11xo988vSgp7UQrTRj1/go-ipfs-util"
22 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
20 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
21 + inet "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/net"
22 + mocknet "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/net/mock"
23 )
24
25 func TestGetFailures(t *testing.T) {
routing/dht/handlers.go
+1 -1
@@ -11,7 +11,7 @@ import (
11 lgbl "github.com/ipfs/go-ipfs/thirdparty/loggables"
12 proto "gx/ipfs/QmZ4Qi3GaRbjcx28Sme5eMH7RQjGkt8wHxt2a65oLaeFEV/gogo-protobuf/proto"
13 u "gx/ipfs/QmZNVWh8LLjAavuQ2JXuFmuYH3C11xo988vSgp7UQrTRj1/go-ipfs-util"
14 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
14 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
15 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
16 )
17
routing/dht/lookup.go
+1 -1
@@ -5,7 +5,7 @@ import (
5 notif "github.com/ipfs/go-ipfs/notifications"
6 kb "github.com/ipfs/go-ipfs/routing/kbucket"
7 pset "github.com/ipfs/go-ipfs/thirdparty/peerset"
8 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
8 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
9 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
10 )
11
routing/dht/notif.go
+2 -2
@@ -1,9 +1,9 @@
1 package dht
2
3 import (
4 - ma "gx/ipfs/QmcobAGsCjYt5DXoq9et9L8yR8er7o7Cu3DTvpaq12jYSz/go-multiaddr"
4 + ma "gx/ipfs/QmYzDkkgAEmrcNzFCiYo6L1dTX4EAG1gZkbtdbd9trL4vd/go-multiaddr"
5
6 - inet "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/net"
6 + inet "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/net"
7 )
8
9 // netNotifiee defines methods to be used with the IpfsDHT
routing/dht/pb/message.go
+3 -3
@@ -1,12 +1,12 @@
1 package dht_pb
2
3 import (
4 - ma "gx/ipfs/QmcobAGsCjYt5DXoq9et9L8yR8er7o7Cu3DTvpaq12jYSz/go-multiaddr"
4 + ma "gx/ipfs/QmYzDkkgAEmrcNzFCiYo6L1dTX4EAG1gZkbtdbd9trL4vd/go-multiaddr"
5
6 key "github.com/ipfs/go-ipfs/blocks/key"
7 - inet "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/net"
8 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
7 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
8 logging "gx/ipfs/QmaDNZ4QMdBdku1YZWBysufYyoQt1negQGNav6PLYarbY8/go-log"
9 + inet "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/net"
10 )
11
12 var log = logging.Logger("dht.pb")
routing/dht/providers.go
+1 -1
@@ -6,7 +6,7 @@ import (
6 key "github.com/ipfs/go-ipfs/blocks/key"
7 goprocess "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess"
8 goprocessctx "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess/context"
9 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
9 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
10
11 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
12 )
routing/dht/providers_test.go
+1 -1
@@ -4,7 +4,7 @@ import (
4 "testing"
5
6 key "github.com/ipfs/go-ipfs/blocks/key"
7 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
7 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
8
9 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
10 )
routing/dht/query.go
+2 -2
@@ -9,8 +9,8 @@ import (
9 pset "github.com/ipfs/go-ipfs/thirdparty/peerset"
10 todoctr "github.com/ipfs/go-ipfs/thirdparty/todocounter"
11 u "gx/ipfs/QmZNVWh8LLjAavuQ2JXuFmuYH3C11xo988vSgp7UQrTRj1/go-ipfs-util"
12 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
13 - queue "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer/queue"
12 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
13 + queue "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer/queue"
14 logging "gx/ipfs/QmaDNZ4QMdBdku1YZWBysufYyoQt1negQGNav6PLYarbY8/go-log"
15
16 process "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess"
routing/dht/records.go
+1 -1
@@ -9,7 +9,7 @@ import (
9 pb "github.com/ipfs/go-ipfs/routing/dht/pb"
10 record "github.com/ipfs/go-ipfs/routing/record"
11 ci "gx/ipfs/QmUEUu1CM8bxBJxc3ZLojAi8evhTr4byQogWstABet79oY/go-libp2p-crypto"
12 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
12 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
13 "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
14 )
15
routing/dht/routing.go
+2 -2
@@ -12,9 +12,9 @@ import (
12 kb "github.com/ipfs/go-ipfs/routing/kbucket"
13 record "github.com/ipfs/go-ipfs/routing/record"
14 pset "github.com/ipfs/go-ipfs/thirdparty/peerset"
15 - inet "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/net"
16 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
15 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
16 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
17 + inet "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/net"
18 )
19
20 // asyncQueryBuffer is the size of buffered channels in async queries. This
routing/kbucket/bucket.go
+1 -1
@@ -4,7 +4,7 @@ import (
4 "container/list"
5 "sync"
6
7 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
7 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
8 )
9
10 // Bucket holds a list of peers.
routing/kbucket/sorting.go
+1 -1
@@ -2,7 +2,7 @@ package kbucket
2
3 import (
4 "container/list"
5 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
5 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
6 "sort"
7 )
8
routing/kbucket/table.go
+1 -1
@@ -7,7 +7,7 @@ import (
7 "sync"
8 "time"
9
10 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
10 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
11 logging "gx/ipfs/QmaDNZ4QMdBdku1YZWBysufYyoQt1negQGNav6PLYarbY8/go-log"
12 )
13
routing/kbucket/table_test.go
+1 -1
@@ -7,7 +7,7 @@ import (
7
8 tu "github.com/ipfs/go-ipfs/thirdparty/testutil"
9
10 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
10 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
11 )
12
13 // Test basic features of the bucket struct
routing/kbucket/util.go
+1 -1
@@ -8,7 +8,7 @@ import (
8 key "github.com/ipfs/go-ipfs/blocks/key"
9 ks "github.com/ipfs/go-ipfs/routing/keyspace"
10 u "gx/ipfs/QmZNVWh8LLjAavuQ2JXuFmuYH3C11xo988vSgp7UQrTRj1/go-ipfs-util"
11 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
11 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
12 )
13
14 // Returned if a routing table query returns no results. This is NOT expected
routing/mock/centralized_client.go
+2 -2
@@ -9,12 +9,12 @@ import (
9 routing "github.com/ipfs/go-ipfs/routing"
10 dhtpb "github.com/ipfs/go-ipfs/routing/dht/pb"
11 "github.com/ipfs/go-ipfs/thirdparty/testutil"
12 + ma "gx/ipfs/QmYzDkkgAEmrcNzFCiYo6L1dTX4EAG1gZkbtdbd9trL4vd/go-multiaddr"
13 proto "gx/ipfs/QmZ4Qi3GaRbjcx28Sme5eMH7RQjGkt8wHxt2a65oLaeFEV/gogo-protobuf/proto"
14 u "gx/ipfs/QmZNVWh8LLjAavuQ2JXuFmuYH3C11xo988vSgp7UQrTRj1/go-ipfs-util"
14 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
15 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
16 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
17 logging "gx/ipfs/QmaDNZ4QMdBdku1YZWBysufYyoQt1negQGNav6PLYarbY8/go-log"
17 - ma "gx/ipfs/QmcobAGsCjYt5DXoq9et9L8yR8er7o7Cu3DTvpaq12jYSz/go-multiaddr"
18 )
19
20 var log = logging.Logger("mockrouter")
routing/mock/centralized_server.go
+1 -1
@@ -9,7 +9,7 @@ import (
9 dssync "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/sync"
10 key "github.com/ipfs/go-ipfs/blocks/key"
11 "github.com/ipfs/go-ipfs/thirdparty/testutil"
12 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
12 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
13 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
14 )
15
routing/mock/centralized_test.go
+1 -1
@@ -7,7 +7,7 @@ import (
7 key "github.com/ipfs/go-ipfs/blocks/key"
8 delay "github.com/ipfs/go-ipfs/thirdparty/delay"
9 "github.com/ipfs/go-ipfs/thirdparty/testutil"
10 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
10 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
11 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
12 )
13
routing/mock/dht.go
+1 -1
@@ -5,8 +5,8 @@ import (
5 sync "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/sync"
6 dht "github.com/ipfs/go-ipfs/routing/dht"
7 "github.com/ipfs/go-ipfs/thirdparty/testutil"
8 - mocknet "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/net/mock"
8 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
9 + mocknet "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/net/mock"
10 )
11
12 type mocknetserver struct {
routing/mock/interface.go
+1 -1
@@ -10,7 +10,7 @@ import (
10 routing "github.com/ipfs/go-ipfs/routing"
11 delay "github.com/ipfs/go-ipfs/thirdparty/delay"
12 "github.com/ipfs/go-ipfs/thirdparty/testutil"
13 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
13 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
14 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
15 )
16
routing/none/none_client.go
+2 -2
@@ -6,10 +6,10 @@ import (
6 key "github.com/ipfs/go-ipfs/blocks/key"
7 repo "github.com/ipfs/go-ipfs/repo"
8 routing "github.com/ipfs/go-ipfs/routing"
9 - p2phost "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/host"
10 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
9 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
10 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
11 logging "gx/ipfs/QmaDNZ4QMdBdku1YZWBysufYyoQt1negQGNav6PLYarbY8/go-log"
12 + p2phost "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/host"
13 )
14
15 var log = logging.Logger("mockrouter")
routing/offline/offline.go
+1 -1
@@ -11,7 +11,7 @@ import (
11 record "github.com/ipfs/go-ipfs/routing/record"
12 ci "gx/ipfs/QmUEUu1CM8bxBJxc3ZLojAi8evhTr4byQogWstABet79oY/go-libp2p-crypto"
13 proto "gx/ipfs/QmZ4Qi3GaRbjcx28Sme5eMH7RQjGkt8wHxt2a65oLaeFEV/gogo-protobuf/proto"
14 - "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
14 + "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
15 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
16 logging "gx/ipfs/QmaDNZ4QMdBdku1YZWBysufYyoQt1negQGNav6PLYarbY8/go-log"
17 )
routing/routing.go
+1 -1
@@ -6,7 +6,7 @@ import (
6
7 key "github.com/ipfs/go-ipfs/blocks/key"
8 ci "gx/ipfs/QmUEUu1CM8bxBJxc3ZLojAi8evhTr4byQogWstABet79oY/go-libp2p-crypto"
9 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
9 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
10 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
11 )
12
routing/supernode/client.go
+2 -2
@@ -8,9 +8,9 @@ import (
8 proto "gx/ipfs/QmZ4Qi3GaRbjcx28Sme5eMH7RQjGkt8wHxt2a65oLaeFEV/gogo-protobuf/proto"
9 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
10
11 - "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/host"
12 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
11 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
12 logging "gx/ipfs/QmaDNZ4QMdBdku1YZWBysufYyoQt1negQGNav6PLYarbY8/go-log"
13 + "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/host"
14
15 key "github.com/ipfs/go-ipfs/blocks/key"
16 routing "github.com/ipfs/go-ipfs/routing"
routing/supernode/proxy/loopback.go
+2 -2
@@ -5,8 +5,8 @@ import (
5 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
6
7 dhtpb "github.com/ipfs/go-ipfs/routing/dht/pb"
8 - inet "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/net"
9 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
8 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
9 + inet "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/net"
10 )
11
12 // RequestHandler handles routing requests locally
routing/supernode/proxy/standard.go
+3 -3
@@ -6,10 +6,10 @@ import (
6 ggio "gx/ipfs/QmZ4Qi3GaRbjcx28Sme5eMH7RQjGkt8wHxt2a65oLaeFEV/gogo-protobuf/io"
7 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
8
9 - host "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/host"
10 - inet "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/net"
11 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
9 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
10 logging "gx/ipfs/QmaDNZ4QMdBdku1YZWBysufYyoQt1negQGNav6PLYarbY8/go-log"
11 + host "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/host"
12 + inet "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/net"
13
14 key "github.com/ipfs/go-ipfs/blocks/key"
15 dhtpb "github.com/ipfs/go-ipfs/routing/dht/pb"
routing/supernode/server.go
+1 -1
@@ -12,7 +12,7 @@ import (
12 dhtpb "github.com/ipfs/go-ipfs/routing/dht/pb"
13 record "github.com/ipfs/go-ipfs/routing/record"
14 proxy "github.com/ipfs/go-ipfs/routing/supernode/proxy"
15 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
15 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
16 )
17
18 // Server handles routing queries using a database backend
test/integration/addcat_test.go
+2 -2
@@ -18,9 +18,9 @@ import (
18 mock "github.com/ipfs/go-ipfs/core/mock"
19 testutil "github.com/ipfs/go-ipfs/thirdparty/testutil"
20 "github.com/ipfs/go-ipfs/thirdparty/unit"
21 - mocknet "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/net/mock"
22 - "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
21 + "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
22 logging "gx/ipfs/QmaDNZ4QMdBdku1YZWBysufYyoQt1negQGNav6PLYarbY8/go-log"
23 + mocknet "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/net/mock"
24 )
25
26 var log = logging.Logger("epictest")
test/integration/bench_cat_test.go
+2 -2
@@ -12,9 +12,9 @@ import (
12 mock "github.com/ipfs/go-ipfs/core/mock"
13 testutil "github.com/ipfs/go-ipfs/thirdparty/testutil"
14 "github.com/ipfs/go-ipfs/thirdparty/unit"
15 - mocknet "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/net/mock"
16 - "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
15 + "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
16 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
17 + mocknet "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/net/mock"
18 )
19
20 func BenchmarkCat1MB(b *testing.B) { benchmarkVarCat(b, unit.MB*1) }
test/integration/bitswap_wo_routing_test.go
+1 -1
@@ -7,8 +7,8 @@ import (
7 "github.com/ipfs/go-ipfs/blocks"
8 "github.com/ipfs/go-ipfs/core"
9 "github.com/ipfs/go-ipfs/core/mock"
10 - mocknet "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/net/mock"
10 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
11 + mocknet "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/net/mock"
12 )
13
14 func TestBitswapWithoutRouting(t *testing.T) {
test/integration/grandcentral_test.go
+2 -2
@@ -20,8 +20,8 @@ import (
20 ds2 "github.com/ipfs/go-ipfs/thirdparty/datastore2"
21 testutil "github.com/ipfs/go-ipfs/thirdparty/testutil"
22 "github.com/ipfs/go-ipfs/thirdparty/unit"
23 - mocknet "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/net/mock"
24 - "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
23 + "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
24 + mocknet "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/net/mock"
25 )
26
27 func TestSupernodeBootstrappedAddCat(t *testing.T) {
test/integration/three_legged_cat_test.go
+2 -2
@@ -15,8 +15,8 @@ import (
15 mock "github.com/ipfs/go-ipfs/core/mock"
16 testutil "github.com/ipfs/go-ipfs/thirdparty/testutil"
17 "github.com/ipfs/go-ipfs/thirdparty/unit"
18 - mocknet "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/net/mock"
19 - "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
18 + "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
19 + mocknet "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/net/mock"
20 )
21
22 func TestThreeLeggedCatTransfer(t *testing.T) {
test/supernode_client/main.go
+2 -2
@@ -14,8 +14,8 @@ import (
14
15 random "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-random"
16 "github.com/ipfs/go-ipfs/thirdparty/ipfsaddr"
17 + ma "gx/ipfs/QmYzDkkgAEmrcNzFCiYo6L1dTX4EAG1gZkbtdbd9trL4vd/go-multiaddr"
18 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
18 - ma "gx/ipfs/QmcobAGsCjYt5DXoq9et9L8yR8er7o7Cu3DTvpaq12jYSz/go-multiaddr"
19
20 "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
21 syncds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/sync"
@@ -29,7 +29,7 @@ import (
29 fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo"
30 ds2 "github.com/ipfs/go-ipfs/thirdparty/datastore2"
31 unit "github.com/ipfs/go-ipfs/thirdparty/unit"
32 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
32 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
33 logging "gx/ipfs/QmaDNZ4QMdBdku1YZWBysufYyoQt1negQGNav6PLYarbY8/go-log"
34 )
35
thirdparty/ipfsaddr/ipfsaddr.go
+2 -2
@@ -3,10 +3,10 @@ package ipfsaddr
3 import (
4 "errors"
5
6 - ma "gx/ipfs/QmcobAGsCjYt5DXoq9et9L8yR8er7o7Cu3DTvpaq12jYSz/go-multiaddr"
6 + ma "gx/ipfs/QmYzDkkgAEmrcNzFCiYo6L1dTX4EAG1gZkbtdbd9trL4vd/go-multiaddr"
7
8 path "github.com/ipfs/go-ipfs/path"
9 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
9 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
10 logging "gx/ipfs/QmaDNZ4QMdBdku1YZWBysufYyoQt1negQGNav6PLYarbY8/go-log"
11 )
12
thirdparty/ipfsaddr/ipfsaddr_test.go
+2 -2
@@ -4,8 +4,8 @@ import (
4 "testing"
5
6 path "github.com/ipfs/go-ipfs/path"
7 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
8 - ma "gx/ipfs/QmcobAGsCjYt5DXoq9et9L8yR8er7o7Cu3DTvpaq12jYSz/go-multiaddr"
7 + ma "gx/ipfs/QmYzDkkgAEmrcNzFCiYo6L1dTX4EAG1gZkbtdbd9trL4vd/go-multiaddr"
8 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
9 )
10
11 var good = []string{
thirdparty/loggables/loggables.go
+2 -2
@@ -11,11 +11,11 @@ import (
11
12 uuid "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/satori/go.uuid"
13
14 - ma "gx/ipfs/QmcobAGsCjYt5DXoq9et9L8yR8er7o7Cu3DTvpaq12jYSz/go-multiaddr"
14 + ma "gx/ipfs/QmYzDkkgAEmrcNzFCiYo6L1dTX4EAG1gZkbtdbd9trL4vd/go-multiaddr"
15
16 logging "gx/ipfs/QmaDNZ4QMdBdku1YZWBysufYyoQt1negQGNav6PLYarbY8/go-log"
17
18 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
18 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
19 )
20
21 // NetConn returns an eventlog.Metadata with the conn addresses
thirdparty/peerset/peerset.go
+1 -1
@@ -1,7 +1,7 @@
1 package peerset
2
3 import (
4 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
4 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
5 "sync"
6 )
7
thirdparty/pollEndpoint/main.go
+2 -2
@@ -10,9 +10,9 @@ import (
10 "os"
11 "time"
12
13 - manet "gx/ipfs/QmTrxSBY8Wqd5aBB4MeizeSzS5xFbK8dQBrYaMsiGnCBhb/go-multiaddr-net"
13 + manet "gx/ipfs/QmUBa4w6CbHJUMeGJPDiMEDWsM93xToK1fTnFXnrC8Hksw/go-multiaddr-net"
14 + ma "gx/ipfs/QmYzDkkgAEmrcNzFCiYo6L1dTX4EAG1gZkbtdbd9trL4vd/go-multiaddr"
15 logging "gx/ipfs/QmaDNZ4QMdBdku1YZWBysufYyoQt1negQGNav6PLYarbY8/go-log"
15 - ma "gx/ipfs/QmcobAGsCjYt5DXoq9et9L8yR8er7o7Cu3DTvpaq12jYSz/go-multiaddr"
16 )
17
18 var (
thirdparty/testutil/gen.go
+2 -2
@@ -10,9 +10,9 @@ import (
10
11 ci "gx/ipfs/QmUEUu1CM8bxBJxc3ZLojAi8evhTr4byQogWstABet79oY/go-libp2p-crypto"
12 u "gx/ipfs/QmZNVWh8LLjAavuQ2JXuFmuYH3C11xo988vSgp7UQrTRj1/go-ipfs-util"
13 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
13 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
14
15 - ma "gx/ipfs/QmcobAGsCjYt5DXoq9et9L8yR8er7o7Cu3DTvpaq12jYSz/go-multiaddr"
15 + ma "gx/ipfs/QmYzDkkgAEmrcNzFCiYo6L1dTX4EAG1gZkbtdbd9trL4vd/go-multiaddr"
16 )
17
18 // ZeroLocalTCPAddress is the "zero" tcp local multiaddr. This means:
thirdparty/testutil/identity.go
+2 -2
@@ -4,8 +4,8 @@ import (
4 "testing"
5
6 ci "gx/ipfs/QmUEUu1CM8bxBJxc3ZLojAi8evhTr4byQogWstABet79oY/go-libp2p-crypto"
7 - peer "gx/ipfs/QmZwZjMVGss5rqYsJVGy18gNbkTJffFyq2x1uJ4e4p3ZAt/go-libp2p-peer"
8 - ma "gx/ipfs/QmcobAGsCjYt5DXoq9et9L8yR8er7o7Cu3DTvpaq12jYSz/go-multiaddr"
7 + ma "gx/ipfs/QmYzDkkgAEmrcNzFCiYo6L1dTX4EAG1gZkbtdbd9trL4vd/go-multiaddr"
8 + peer "gx/ipfs/QmZpD74pUj6vuxTp1o6LhA3JavC2Bvh9fsWPPVvHnD9sE7/go-libp2p-peer"
9 )
10
11 type Identity interface {