diff --git a/README.md b/README.md index 6052bf9..a8806e6 100644 --- a/README.md +++ b/README.md @@ -32,49 +32,48 @@ go get github.com/FollowTheProcess/cli@latest package main import ( - "fmt" - "os" + "fmt" + "os" - "github.com/FollowTheProcess/cli" + "github.com/FollowTheProcess/cli" ) func main() { - if err := run(); err != nil { - fmt.Fprintf(os.Stderr, "Error: %v\n", err) - os.Exit(1) + if err := run(); err != nil { + fmt.Fprintf(os.Stderr, "Error: %v\n", err) + os.Exit(1) } } func run() error { - var count int - cmd, err := cli.New( - "quickstart", - cli.Short("Short description of your command"), - cli.Long("Much longer text..."), - cli.Version("v1.2.3"), - cli.Commit("7bcac896d5ab67edc5b58632c821ec67251da3b8"), - cli.BuildDate("2024-08-17T10:37:30Z"), - cli.Allow(cli.MinArgs(1)), // Must have at least one argument - cli.Stdout(os.Stdout), - cli.Example("Do a thing", "quickstart something"), - cli.Example("Count the things", "quickstart something --count 3"), - cli.Flag(&count, "count", 'c', 0, "Count the things"), - cli.Run(runQuickstart(&count)), - ) - if err != nil { - return err - } - - return cmd.Execute() + var count int + cmd, err := cli.New( + "quickstart", + cli.Short("Short description of your command"), + cli.Long("Much longer text..."), + cli.Version("v1.2.3"), + cli.Commit("7bcac896d5ab67edc5b58632c821ec67251da3b8"), + cli.BuildDate("2024-08-17T10:37:30Z"), + cli.Allow(cli.MinArgs(1)), // Must have at least one argument + cli.Stdout(os.Stdout), + cli.Example("Do a thing", "quickstart something"), + cli.Example("Count the things", "quickstart something --count 3"), + cli.Flag(&count, "count", 'c', 0, "Count the things"), + cli.Run(runQuickstart(&count)), + ) + if err != nil { + return err + } + + return cmd.Execute() } func runQuickstart(count *int) func(cmd *cli.Command, args []string) error { - return func(cmd *cli.Command, args []string) error { - fmt.Fprintf(cmd.Stdout(), "Hello from quickstart!, my args were: %v, count was %d\n", args, *count) - return nil - } + return func(cmd *cli.Command, args []string) error { + fmt.Fprintf(cmd.Stdout(), "Hello from quickstart!, my args were: %v, count was %d\n", args, *count) + return nil + } } - ``` Will get you the following: