import ( "fmt" "os" "github.com/urfave/cli" ) func main() { app := cli.NewApp() app.Usage = "My awesome CLI app" app.ArgsUsage = "In this example, we create a new CLI app and define the flags and usage information. We then define the app's main action, which gets executed when the CLI tool is run. Inside the action function, we check that a valid filename argument is provided and that the file actually exists. We also set the verbose flag if it is specified, and use it to print out some additional information. Overall, the go github.com/urfave.cli package library provides an easy way to handle command-line arguments and flags in your Go applications, allowing developers to create powerful CLI tools with ease." app.Flags = []cli.Flag{ cli.BoolFlag{ Name: "verbose", Usage: "enable verbose output", }, } app.Action = func(c *cli.Context) error { if c.Args().Len() == 0 { return cli.NewExitError("missing filename", 1) } filename := c.Args().Get(0) if _, err := os.Stat(filename); os.IsNotExist(err) { return cli.NewExitError("file does not exist", 1) } if c.Bool("verbose") { fmt.Printf("processing file %s...\n", filename) } // continue processing the file return nil } err := app.Run(os.Args) if err != nil { fmt.Fprintf(os.Stderr, "error: %s\n", err.Error()) os.Exit(1) } }