Cobra vs urfave/cli

Which CLI Library to Use in Go

Cli
Use spf13/cobra for complex CLIs with subcommands and urfave/cli for simpler, lightweight tools.

Choose spf13/cobra for large, scalable applications requiring nested commands and shell completion, or urfave/cli for simpler, single-binary tools.

// Example: Initialize a Cobra command
import "github.com/spf13/cobra"

func main() {
	var rootCmd = &cobra.Command{
		Use: "myapp",
		Short: "A brief description of myapp",
		Run: func(cmd *cobra.Command, args []string) {
			fmt.Println("Hello, World!")
		},
	}
	rootCmd.Execute()
}