commit
d38a3b82a6
@ -137,7 +137,7 @@ Setting and querying flags is simple.
|
||||
``` go
|
||||
...
|
||||
app.Flags = []cli.Flag {
|
||||
cli.StringFlag{"lang", "english", "language for the greeting"},
|
||||
cli.StringFlag{Name: "lang", Value: "english", Usage: "language for the greeting"},
|
||||
}
|
||||
app.Action = func(c *cli.Context) {
|
||||
name := "someone"
|
||||
@ -159,7 +159,7 @@ You can set alternate (or short) names for flags by providing a comma-delimited
|
||||
|
||||
``` go
|
||||
app.Flags = []cli.Flag {
|
||||
cli.StringFlag{"lang, l", "english", "language for the greeting"},
|
||||
cli.StringFlag{Name: "lang, l", Value: "english", Usage: "language for the greeting"},
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -43,7 +43,7 @@ func ExampleAppSubcommand() {
|
||||
Usage: "sends a greeting in english",
|
||||
Description: "greets someone in english",
|
||||
Flags: []cli.Flag{
|
||||
cli.StringFlag{"name", "Bob", "Name of the person to greet"},
|
||||
cli.StringFlag{Name: "name", Value: "Bob", Usage: "Name of the person to greet"},
|
||||
},
|
||||
Action: func(c *cli.Context) {
|
||||
fmt.Println("Hello,", c.String("name"))
|
||||
@ -255,11 +255,11 @@ func TestApp_ParseSliceFlags(t *testing.T) {
|
||||
var expectedStringSlice = []string{"8.8.8.8", "8.8.4.4"}
|
||||
|
||||
if !IntsEquals(parsedIntSlice, expectedIntSlice) {
|
||||
t.Errorf("%s does not match %s", parsedIntSlice, expectedIntSlice)
|
||||
t.Errorf("%v does not match %v", parsedIntSlice, expectedIntSlice)
|
||||
}
|
||||
|
||||
if !StrsEquals(parsedStringSlice, expectedStringSlice) {
|
||||
t.Errorf("%s does not match %s", parsedStringSlice, expectedStringSlice)
|
||||
t.Errorf("%v does not match %v", parsedStringSlice, expectedStringSlice)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,9 @@
|
||||
package cli_test
|
||||
|
||||
import (
|
||||
"github.com/codegangsta/cli"
|
||||
"os"
|
||||
|
||||
"github.com/codegangsta/cli"
|
||||
)
|
||||
|
||||
func Example() {
|
||||
@ -47,7 +48,7 @@ func ExampleSubcommand() {
|
||||
Usage: "sends a greeting in english",
|
||||
Description: "greets someone in english",
|
||||
Flags: []cli.Flag{
|
||||
cli.StringFlag{"name", "Bob", "Name of the person to greet"},
|
||||
cli.StringFlag{Name: "name", Value: "Bob", Usage: "Name of the person to greet"},
|
||||
},
|
||||
Action: func(c *cli.Context) {
|
||||
println("Hello, ", c.String("name"))
|
||||
@ -57,7 +58,7 @@ func ExampleSubcommand() {
|
||||
ShortName: "sp",
|
||||
Usage: "sends a greeting in spanish",
|
||||
Flags: []cli.Flag{
|
||||
cli.StringFlag{"surname", "Jones", "Surname of the person to greet"},
|
||||
cli.StringFlag{Name: "surname", Value: "Jones", Usage: "Surname of the person to greet"},
|
||||
},
|
||||
Action: func(c *cli.Context) {
|
||||
println("Hola, ", c.String("surname"))
|
||||
@ -67,7 +68,7 @@ func ExampleSubcommand() {
|
||||
ShortName: "fr",
|
||||
Usage: "sends a greeting in french",
|
||||
Flags: []cli.Flag{
|
||||
cli.StringFlag{"nickname", "Stevie", "Nickname of the person to greet"},
|
||||
cli.StringFlag{Name: "nickname", Value: "Stevie", Usage: "Nickname of the person to greet"},
|
||||
},
|
||||
Action: func(c *cli.Context) {
|
||||
println("Bonjour, ", c.String("nickname"))
|
||||
|
Loading…
Reference in New Issue
Block a user