Skip to content

Commit

Permalink
Merge 1b44630 into 76b5294
Browse files Browse the repository at this point in the history
  • Loading branch information
goofinator committed Dec 4, 2019
2 parents 76b5294 + 1b44630 commit acb89ba
Show file tree
Hide file tree
Showing 3 changed files with 463 additions and 4 deletions.
75 changes: 74 additions & 1 deletion argparse.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,18 @@ func (o *Command) File(short string, long string, flag int, perm os.FileMode, op
}

// List creates new list argument. This is the argument that is allowed to be present multiple times on CLI.
// All appearances of this argument on CLI will be collected into the list of strings. If no argument
// All appearances of this argument on CLI will be collected into the list of default type values ​​which is strings. If no argument
// provided, then the list is empty. Takes same parameters as String
// Returns a pointer the list of strings.
func (o *Command) List(short string, long string, opts *Options) *[]string {
return o.StringList(short, long, opts)
}

// StringList creates new string list argument. This is the argument that is allowed to be present multiple times on CLI.
// All appearances of this argument on CLI will be collected into the list of strings. If no argument
// provided, then the list is empty. Takes same parameters as String
// Returns a pointer the list of strings.
func (o *Command) StringList(short string, long string, opts *Options) *[]string {
result := make([]string, 0)

a := &arg{
Expand All @@ -297,6 +305,71 @@ func (o *Command) List(short string, long string, opts *Options) *[]string {
return &result
}

// IntList creates new integer list argument. This is the argument that is allowed to be present multiple times on CLI.
// All appearances of this argument on CLI will be collected into the list of integers. If no argument
// provided, then the list is empty. Takes same parameters as Int
// Returns a pointer the list of integers.
func (o *Command) IntList(short string, long string, opts *Options) *[]int {
result := make([]int, 0)

a := &arg{
result: &result,
sname: short,
lname: long,
size: 2,
opts: opts,
unique: false,
}

o.addArg(a)

return &result
}

// FloatList creates new float list argument. This is the argument that is allowed to be present multiple times on CLI.
// All appearances of this argument on CLI will be collected into the list of float64 values. If no argument
// provided, then the list is empty. Takes same parameters as Float
// Returns a pointer the list of float64 values.
func (o *Command) FloatList(short string, long string, opts *Options) *[]float64 {
result := make([]float64, 0)

a := &arg{
result: &result,
sname: short,
lname: long,
size: 2,
opts: opts,
unique: false,
}

o.addArg(a)

return &result
}

// FileList creates new file list argument. This is the argument that is allowed to be present multiple times on CLI.
// All appearances of this argument on CLI will be collected into the list of os.File values. If no argument
// provided, then the list is empty. Takes same parameters as File
// Returns a pointer the list of os.File values.
func (o *Command) FileList(short string, long string, flag int, perm os.FileMode, opts *Options) *[]os.File {
result := make([]os.File, 0)

a := &arg{
result: &result,
sname: short,
lname: long,
size: 2,
opts: opts,
unique: false,
fileFlag: flag,
filePerm: perm,
}

o.addArg(a)

return &result
}

// Selector creates a selector argument. Selector argument works in the same way as String argument, with
// the difference that the string value must be from the list of options provided by the program.
// Takes short and long names, argument options and a slice of strings which are allowed values
Expand Down
Loading

0 comments on commit acb89ba

Please sign in to comment.