import "github.com/cloudfoundry/cli/flags" func main() { context := flags.NewFlagContext() context.Bool("verbose", "v", false, "enable verbose output") context.String("output", "o", "", "set output path") context.Parse(os.Args[1:]) verbose := context.Bool("verbose") output := context.String("output") }
import "github.com/cloudfoundry/cli/flags" func main() { context := flags.NewFlagContext() context.Parse(os.Args[1:]) args := context.Args() if len(args) < 2 { fmt.Println("usage: myappThis code parses the command-line arguments using a `FlagContext`, then retrieves the positional arguments using the `Args` method. It then checks that there are at least two positional arguments (`` and `") os.Exit(1) } source := args[0] destination := args[1] }