Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(416)

Side by Side Diff: common/flag/stringlistflag/stringlistflag_test.go

Issue 2107283002: kitchen: add -python-path (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: rebased Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The LUCI Authors. All rights reserved. 1 // Copyright 2016 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package stringsetflag 5 package stringlistflag
6 6
7 import ( 7 import (
8 "flag" 8 "flag"
9 "fmt" 9 "fmt"
10 "os" 10 "os"
11 ) 11 )
12 12
13 // Example demonstrates how to use flagenum to create bindings for a custom 13 // Example demonstrates how to use stringlistflag.
14 // type.
15 func Example() { 14 func Example() {
16 » sset := Flag{} 15 » list := Flag{}
17 16
18 fs := flag.NewFlagSet("test", flag.ContinueOnError) 17 fs := flag.NewFlagSet("test", flag.ContinueOnError)
19 » fs.Var(&sset, "color", "favorite color, may be repeated.") 18 » fs.Var(&list, "color", "favorite color, may be repeated.")
20 fs.SetOutput(os.Stdout) 19 fs.SetOutput(os.Stdout)
21 20
22 fs.PrintDefaults() 21 fs.PrintDefaults()
23 22
24 // Flag parsing. 23 // Flag parsing.
25 fs.Parse([]string{"-color", "Violet", "-color", "Red", "-color", "Violet "}) 24 fs.Parse([]string{"-color", "Violet", "-color", "Red", "-color", "Violet "})
26 » fmt.Printf("Value is: %s\n", sset) 25 » fmt.Printf("Value is: %s\n", list)
27
28 » fmt.Println("Likes Blue:", sset.Data.Has("Blue"))
29 » fmt.Println("Likes Red:", sset.Data.Has("Red"))
30 26
31 // Output: 27 // Output:
32 // -color value 28 // -color value
33 // favorite color, may be repeated. 29 // favorite color, may be repeated.
34 » // Value is: Red,Violet 30 » // Value is: Violet, Red, Violet
35 » // Likes Blue: false
36 » // Likes Red: true
37 } 31 }
OLDNEW
« no previous file with comments | « common/flag/stringlistflag/stringlistflag.go ('k') | common/flag/stringsetflag/stringsetflag_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698