Merge branch 'master' into v2-master-merge

main
Ajitem Sahasrabuddhe 5 years ago
commit a9d5b68df5
No known key found for this signature in database
GPG Key ID: 5B0EE10DAA76876C

@ -104,11 +104,7 @@ import (
...
```
### Pinning to the `v1` releases
Similarly to the section above describing use of the `v2` branch, if one wants
to avoid any unexpected compatibility pains once `v2` becomes `master`, then
pinning to `v1` is an acceptable option, e.g.:
### Using `v1` releases
```
$ go get github.com/urfave/cli
@ -711,6 +707,7 @@ package main
import (
"fmt"
"log"
"os"
"github.com/urfave/cli/v2"
@ -738,6 +735,7 @@ func main() {
#### Default Values for help output
<<<<<<< HEAD
Sometimes it's useful to specify a flag's default help-text value within the flag declaration. This can be useful if the default value for a flag is a computed value. The default value can be set via the `DefaultText` struct field.
For example this:
@ -768,6 +766,8 @@ func main() {
},
}
=======
>>>>>>> master
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
@ -775,12 +775,15 @@ func main() {
}
```
<<<<<<< HEAD
Will result in help output like:
```
--port value Use a randomized port (default: random)
```
=======
>>>>>>> master
#### Precedence
The precedence for flag value sources is as follows (highest to lowest):
@ -882,6 +885,7 @@ import (
)
func main() {
<<<<<<< HEAD
app := &cli.App{
Commands: []*cli.Command{
{
@ -895,6 +899,21 @@ func main() {
Name: "remove",
Category: "template",
},
=======
app := cli.NewApp()
app.Commands = []cli.Command{
{
Name: "noop",
},
{
Name: "add",
Category: "Template actions",
},
{
Name: "remove",
Category: "Template actions",
>>>>>>> master
},
}

@ -1,3 +1,5 @@
// Code generated by fg; DO NOT EDIT.
package altsrc
import (

@ -203,6 +203,5 @@ func jsonGetValue(key string, m map[string]interface{}) (interface{}, error) {
type jsonSource struct {
file string
deserialized map[string]interface {
}
deserialized map[string]interface{}
}

@ -1,8 +1,3 @@
// Disabling building of toml support in cases where golang is 1.0 or 1.1
// as the encoding library is not implemented or supported.
// +build go1.2
package altsrc
import (

@ -1,8 +1,3 @@
// Disabling building of toml support in cases where golang is 1.0 or 1.1
// as the encoding library is not implemented or supported.
// +build go1.2
package altsrc
import (

@ -1,8 +1,3 @@
// Disabling building of yaml support in cases where golang is 1.0 or 1.1
// as the encoding library is not implemented or supported.
// +build go1.2
package altsrc
import (

@ -1,8 +1,3 @@
// Disabling building of yaml support in cases where golang is 1.0 or 1.1
// as the encoding library is not implemented or supported.
// +build go1.2
package altsrc
import (

@ -11,14 +11,14 @@ import (
"time"
)
//var (
// changeLogURL = "https://github.com/urfave/cli/blob/master/CHANGELOG.md"
// appActionDeprecationURL = fmt.Sprintf("%s#deprecated-cli-app-action-signature", changeLogURL)
// contactSysadmin = "This is an error in the application. Please contact the distributor of this application if this is not you."
// errInvalidActionType = NewExitError("ERROR invalid Action type. "+
// fmt.Sprintf("Must be `func(*Context`)` or `func(*Context) error). %s", contactSysadmin)+
// fmt.Sprintf("See %s", appActionDeprecationURL), 2)
//)
var (
changeLogURL = "https://github.com/urfave/cli/blob/master/CHANGELOG.md"
appActionDeprecationURL = fmt.Sprintf("%s#deprecated-cli-app-action-signature", changeLogURL)
contactSysadmin = "This is an error in the application. Please contact the distributor of this application if this is not you."
errInvalidActionType = NewExitError("ERROR invalid Action type. "+
fmt.Sprintf("Must be `func(*Context`)` or `func(*Context) error). %s", contactSysadmin)+
fmt.Sprintf("See %s", appActionDeprecationURL), 2)
)
// App is the main structure of a cli application. It is recommended that
// an app be created with the cli.NewApp() function
@ -532,3 +532,20 @@ func (a *Author) String() string {
return fmt.Sprintf("%v%v", a.Name, e)
}
// HandleAction attempts to figure out which Action signature was used. If
// it's an ActionFunc or a func with the legacy signature for Action, the func
// is run!
func HandleAction(action interface{}, context *Context) (err error) {
switch a := action.(type) {
case ActionFunc:
return a(context)
case func(*Context) error:
return a(context)
case func(*Context): // deprecated function signature
a(context)
return nil
}
return errInvalidActionType
}

@ -12,15 +12,23 @@ cache:
environment:
GOPATH: C:\gopath
GOVERSION: 1.11.x
<<<<<<< HEAD
GO111MODULE: on
GOPROXY: https://proxy.golang.org
=======
>>>>>>> master
install:
- set PATH=%GOPATH%\bin;C:\go\bin;%PATH%
- go version
- go env
<<<<<<< HEAD
- go get github.com/urfave/gfmrun/cmd/gfmrun
- go mod vendor
=======
- go get github.com/urfave/gfmrun/...
- go get -v -t ./...
>>>>>>> master
build_script:
- go run build.go vet

@ -98,7 +98,6 @@ func (c *Context) FlagNames() []string {
var names []string
for _, ctx := range c.Lineage() {
ctx.flagSet.Visit(makeFlagNameVisitor(&names))
}
return names
}

@ -102,13 +102,14 @@ func prepareFlags(
sep, opener, closer, value string,
addDetails bool,
) []string {
var args []string
args := []string{}
for _, f := range flags {
flag, ok := f.(DocGenerationFlag)
if !ok {
continue
}
modifiedArg := opener
for _, s := range flag.Names() {
trimmed := strings.TrimSpace(s)
if len(modifiedArg) > len(opener) {

@ -39,6 +39,7 @@ func (i *Int64Slice) Set(value string) error {
}
i.slice = append(i.slice, tmp)
return nil
}
@ -144,7 +145,13 @@ func (f *Int64SliceFlag) Apply(set *flag.FlagSet) error {
// Int64Slice looks up the value of a local Int64SliceFlag, returns
// nil if not found
func (c *Context) Int64Slice(name string) []int64 {
if fs := lookupFlagSet(name, c); fs != nil {
return lookupInt64Slice(name, c.flagSet)
}
// GlobalInt64Slice looks up the value of a global Int64SliceFlag, returns
// nil if not found
func (c *Context) GlobalInt64Slice(name string) []int64 {
if fs := lookupGlobalFlagSet(name, c); fs != nil {
return lookupInt64Slice(name, fs)
}
return nil

@ -33,6 +33,7 @@ func (s *StringSlice) Set(value string) error {
}
s.slice = append(s.slice, value)
return nil
}
@ -132,6 +133,7 @@ func (f *StringSliceFlag) Apply(set *flag.FlagSet) error {
}
set.Var(f.Value, name, f.Usage)
}
return nil
}

@ -229,21 +229,6 @@ var prefixStringFlagTests = []struct {
}, expected: "name: config,c, ph: CONFIG\tLoad configuration from CONFIG (default: \"config.json\")"},
}
//func TestFlagNamePrefixer(t *testing.T) {
// defer func() {
// FlagNamePrefixer = prefixedNames
// }()
//
// for _, test := range prefixStringFlagTests {
// FlagNamePrefixer = test.prefixer
// fl := StringFlag{Name: test.name, Aliases: test.aliases, Usage: test.usage, Value: test.value}
// output := fl.String()
// if output != test.expected {
// t.Errorf("%q does not match %q", output, test.expected)
// }
// }
//}
func TestStringFlagApply_SetsAllNames(t *testing.T) {
v := "mmm"
fl := StringFlag{Name: "hay", Aliases: []string{"H", "hayyy"}, Destination: &v}

Loading…
Cancel
Save