| 1 | // Copyright 2013 Google Inc. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | package getoptscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/ |
| 6 | |
| 7 | import "stringsscip-go gomod github.com/golang/go/src go1.13 strings/" |
| 8 | |
| 9 | type listValuescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/listValue# []string |
| 10 | |
| 11 | func (s *listValuescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/listValue#) Setscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/listValue#Set().(value string, opt Optionscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Option#) error { |
| 12 | a := stringsscip-go gomod github.com/golang/go/src go1.13 strings/.Splitscip-go gomod github.com/golang/go/src go1.13 strings/Split().(value, ",") |
| 13 | // If this is the first time we are seen then nil out the |
| 14 | // default value. |
| 15 | if opt.Countscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Option#Count.() <= 1 { |
| 16 | *s = nil |
| 17 | } |
| 18 | *s = append(*s, a...) |
| 19 | return nil |
| 20 | } |
| 21 | |
| 22 | func (s *listValuescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/listValue#) Stringscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/listValue#String().() string { |
| 23 | return stringsscip-go gomod github.com/golang/go/src go1.13 strings/.Joinscip-go gomod github.com/golang/go/src go1.13 strings/Join().([]string(*s), ",") |
| 24 | } |
| 25 | |
| 26 | // List creates an option that returns a slice of strings. The parameters |
| 27 | // passed are converted from a comma separated value list into a slice. |
| 28 | // Subsequent occurrences append to the list. |
| 29 | func Listscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/List().(name rune, helpvalue ...string) *[]string { |
| 30 | return CommandLinescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/CommandLine..Listscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#List().(name, helpvalue...) |
| 31 | } |
| 32 | |
| 33 | func (s *Setscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#) Listscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#List().(name rune, helpvalue ...string) *[]string { |
| 34 | p := []string{} |
| 35 | s.ListVarscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#ListVar().(&p, name, helpvalue...) |
| 36 | return &p |
| 37 | } |
| 38 | |
| 39 | func ListLongscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/ListLong().(name string, short rune, helpvalue ...string) *[]string { |
| 40 | return CommandLinescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/CommandLine..ListLongscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#ListLong().(name, short, helpvalue...) |
| 41 | } |
| 42 | |
| 43 | func (s *Setscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#) ListLongscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#ListLong().(name string, short rune, helpvalue ...string) *[]string { |
| 44 | p := []string{} |
| 45 | s.ListVarLongscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#ListVarLong().(&p, name, short, helpvalue...) |
| 46 | return &p |
| 47 | } |
| 48 | |
| 49 | // ListVar creates a list option and places the values in p. If p is pointing |
| 50 | // to a list of values then those are considered the default values. The first |
| 51 | // time name is seen in the options the list will be set to list specified by |
| 52 | // the parameter to the option. Subsequent instances of the option will append |
| 53 | // to the list. |
| 54 | func ListVarscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/ListVar().(p *[]string, name rune, helpvalue ...string) Optionscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Option# { |
| 55 | return CommandLinescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/CommandLine..ListVarscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#ListVar().(p, name, helpvalue...) |
| 56 | } |
| 57 | |
| 58 | func (s *Setscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#) ListVarscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#ListVar().(p *[]string, name rune, helpvalue ...string) Optionscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Option# { |
| 59 | return s.ListVarLongscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#ListVarLong().(p, "", name, helpvalue...) |
| 60 | } |
| 61 | |
| 62 | func ListVarLongscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/ListVarLong().(p *[]string, name string, short rune, helpvalue ...string) Optionscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Option# { |
| 63 | return CommandLinescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/CommandLine..ListVarLongscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#ListVarLong().(p, name, short, helpvalue...) |
| 64 | } |
| 65 | |
| 66 | func (s *Setscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#) ListVarLongscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#ListVarLong().(p *[]string, name string, short rune, helpvalue ...string) Optionscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Option# { |
| 67 | opt := s.VarLongscip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/Set#VarLong().((*listValuescip-go gomod github.com/pborman/getopt . `github.com/pborman/getopt`/listValue#)(p), name, short, helpvalue...) |
| 68 | return opt |
| 69 | } |