Go Fmt
This commit is contained in:
parent
ff1c0b58dd
commit
7c383b0d16
@ -266,7 +266,7 @@ func reorderArgs(args []string) []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func translateShortOptions(set *flag.FlagSet, flagArgs Args) []string {
|
func translateShortOptions(set *flag.FlagSet, flagArgs Args) []string {
|
||||||
allCharsFlags := func (s string) bool {
|
allCharsFlags := func(s string) bool {
|
||||||
for i := range s {
|
for i := range s {
|
||||||
f := set.Lookup(string(s[i]))
|
f := set.Lookup(string(s[i]))
|
||||||
if f == nil {
|
if f == nil {
|
||||||
|
@ -59,9 +59,9 @@ func TestCommandFlagParsing(t *testing.T) {
|
|||||||
|
|
||||||
func TestParseAndRunShortOpts(t *testing.T) {
|
func TestParseAndRunShortOpts(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
testArgs []string
|
testArgs []string
|
||||||
expectedErr error
|
expectedErr error
|
||||||
expectedArgs []string
|
expectedArgs []string
|
||||||
}{
|
}{
|
||||||
{[]string{"foo", "test", "-a"}, nil, []string{}},
|
{[]string{"foo", "test", "-a"}, nil, []string{}},
|
||||||
{[]string{"foo", "test", "-c", "arg1", "arg2"}, nil, []string{"arg1", "arg2"}},
|
{[]string{"foo", "test", "-c", "arg1", "arg2"}, nil, []string{"arg1", "arg2"}},
|
||||||
@ -71,18 +71,18 @@ func TestParseAndRunShortOpts(t *testing.T) {
|
|||||||
{[]string{"foo", "test", "-cf"}, nil, []string{}},
|
{[]string{"foo", "test", "-cf"}, nil, []string{}},
|
||||||
{[]string{"foo", "test", "-acf"}, nil, []string{}},
|
{[]string{"foo", "test", "-acf"}, nil, []string{}},
|
||||||
{[]string{"foo", "test", "-invalid"}, errors.New("flag provided but not defined: -invalid"), []string{}},
|
{[]string{"foo", "test", "-invalid"}, errors.New("flag provided but not defined: -invalid"), []string{}},
|
||||||
{[]string{"foo", "test", "-acf", "arg1", "-invalid"}, nil, []string{"arg1" ,"-invalid"}},
|
{[]string{"foo", "test", "-acf", "arg1", "-invalid"}, nil, []string{"arg1", "-invalid"}},
|
||||||
}
|
}
|
||||||
|
|
||||||
var args []string
|
var args []string
|
||||||
cmd := Command{
|
cmd := Command{
|
||||||
Name: "test",
|
Name: "test",
|
||||||
Usage: "this is for testing",
|
Usage: "this is for testing",
|
||||||
Description: "testing",
|
Description: "testing",
|
||||||
Action: func(c *Context) error {
|
Action: func(c *Context) error {
|
||||||
args = c.Args()
|
args = c.Args()
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
SkipArgReorder: true,
|
SkipArgReorder: true,
|
||||||
UseShortOptionHandling: true,
|
UseShortOptionHandling: true,
|
||||||
Flags: []Flag{
|
Flags: []Flag{
|
||||||
|
@ -1052,7 +1052,7 @@ func TestParseBoolShortOptionHandle(t *testing.T) {
|
|||||||
a := App{
|
a := App{
|
||||||
Commands: []Command{
|
Commands: []Command{
|
||||||
{
|
{
|
||||||
Name: "foobar",
|
Name: "foobar",
|
||||||
UseShortOptionHandling: true,
|
UseShortOptionHandling: true,
|
||||||
Action: func(ctx *Context) error {
|
Action: func(ctx *Context) error {
|
||||||
if ctx.Bool("serve") != true {
|
if ctx.Bool("serve") != true {
|
||||||
|
Loading…
Reference in New Issue
Block a user