Merge pull request #112 from AudriusButkevicius/swap
Add Args.Swap command for swapping arguments
This commit is contained in:
commit
27ecc97192
@ -140,6 +140,15 @@ func (a Args) Present() bool {
|
|||||||
return len(a) != 0
|
return len(a) != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Swaps arguments at the given indexes
|
||||||
|
func (a Args) Swap(from, to int) error {
|
||||||
|
if from >= len(a) || to >= len(a) {
|
||||||
|
return errors.New("index out of range")
|
||||||
|
}
|
||||||
|
a[from], a[to] = a[to], a[from]
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func lookupInt(name string, set *flag.FlagSet) int {
|
func lookupInt(name string, set *flag.FlagSet) int {
|
||||||
f := set.Lookup(name)
|
f := set.Lookup(name)
|
||||||
if f != nil {
|
if f != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user