func rootCommand()

in internal/cmd/root.go [34:66]


func rootCommand() *cobra.Command {
	cmd := &cobra.Command{
		Use:   "ec2-macos-utils",
		Short: "utilities for EC2 macOS instances",
		Long: strings.TrimSpace(`
This command provides utilities for common tasks on EC2 macOS instances to simplify operation & administration.

This includes disk manipulation and system configuration helpers. Tasks are reached through subcommands, each with 
help text and usages that accompany them.
`),
		Version:           build.Version,
		SilenceUsage:      true,
		DisableAutoGenTag: true,
	}

	versionTemplate := "{{.Name}} {{.Version}} [%s]\n\n%s\n"
	cmd.SetVersionTemplate(fmt.Sprintf(versionTemplate, build.CommitDate, shortLicenseText))

	var verbose bool
	cmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Enable verbose logging output")

	cmd.PersistentPreRunE = func(cmd *cobra.Command, args []string) error {
		level := logrus.InfoLevel
		if verbose {
			level = logrus.DebugLevel
		}
		setupLogging(level)

		return nil
	}

	return cmd
}