mow.cli
mow.cli copied to clipboard
Cannot use exclusive choices with OPTIONS
I'd like to use exclusive choices with OPTIONS. It seems I can't do that currently. Example code follows below.
With the spec line app.Spec = "(--one | --two) [OPTIONS]"
, it is legal for the user to call main --one --two
.
With the spec line app.Spec = "(--one | --two)"
, the user must choice between using --one
or --two
.
In this example, I'm looking for the latter, to force the user to specify --one
OR --two
and separately allow them to specific --recursive
package main
import (
"fmt"
"os"
"github.com/jawher/mow.cli"
)
func main() {
app := cli.App("cp", "Copy files around")
app.Spec = "(--one | --two) [OPTIONS]"
//app.Spec = "(--one | --two)"
var (
recursive = app.BoolOpt("r recursive", false, "Copy files recursively")
one = app.BoolOpt("one", false, "One")
two = app.BoolOpt("two", false, "Two")
)
app.Action = func() {
fmt.Println("hello")
fmt.Printf("One: %v | Two: %v | Recursive: %v\n", *one, *two, *recursive)
}
app.Run(os.Args)
}