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)
}
}