main function

main is the entry point of the CLI application.

Show/Hide Function Body
{
	// Create a new root command for the CLI.
	rootCmd := root.NewRootCommand("mycli", "mycli [command]", "A simple CLI example", "1.0.0")

	// Add flags to the root command.
	rootCmd.AddBoolFlag("verbose", "v", "Enable verbose output", false, false, false)

	// Add subcommands to the root command.
	rootCmd.AddCommand(commands.NewAddCommand())
	rootCmd.AddCommand(commands.NewRemoveCommand())
	rootCmd.AddCommand(commands.NewListCommand())

	rootCmd.AddAlias("ra", "remove", "all")

	// Execute the root command and handle any errors.
	if err := rootCmd.Execute(); err != nil {
		fmt.Fprintf(os.Stderr, "Error: %v\n", err)
		os.Exit(1)
	}
}

fmt import

Import example:

import "fmt"

os import

Import example:

import "os"

github.com/mirkobrombin/go-cli-builder/examples/v1/commands import

Import example:

import "github.com/mirkobrombin/go-cli-builder/examples/v1/commands"

github.com/mirkobrombin/go-cli-builder/v1/root import

Import example:

import "github.com/mirkobrombin/go-cli-builder/v1/root"