// Example 1: Accessing arguments and options func sayHello(ctx *cli.Context) error { name := ctx.Args().First() if name == "" { name = "World" } if ctx.Bool("yell") { fmt.Printf("HELLO %s!\n", strings.ToUpper(name)) } else { fmt.Printf("Hello %s\n", name) } return nil } // Example 2: Handling subcommands func main() { app := cli.NewApp() app.Usage = "My cool CLI tool" app.Commands = []*cli.Command{ { Name: "greet", Usage: "Greet somebody", Aliases: []string{"hello"}, Action: sayHello, Flags: []cli.Flag{ &cli.BoolFlag{Name: "yell", Usage: "Yell instead of speaking normally"}, }, }, } app.Run(os.Args) }In the first example, `ctx.Args()` is used to retrieve the arguments passed to the command (in this case, a single name). The `Bool()` method is used to retrieve an optional command-line flag named `yell`. This example is a simple implementation of a "Hello, World!" program that can optionally yell at the user. The second example demonstrates how to use `Context` to handle subcommands. The `cli.Command` struct represents a subcommand, and its `Action` field is a function that will be called when the subcommand is invoked. It also defines a `Flags` field that specifies any command-line options that the subcommand accepts. This example registers a single subcommand named `greet` (with an alias `hello`). When the `greet` command is invoked, it calls the `sayHello` function from the previous example. Overall, the `github.com.digitalocean.doctl.godeps._workspace.src.github.com.codegangsta.cli` package library provides a robust framework for building and organizing complex command-line applications in Go.