feat(golang-rewrite): add boilerplate for cobra CLI commands

This commit is contained in:
Trevor Brown 2024-02-12 20:00:41 -05:00
parent a08b71219d
commit 229ca564f7
2 changed files with 41 additions and 2 deletions

37
commands/commands.go Normal file
View File

@ -0,0 +1,37 @@
package commands
import (
"fmt"
"os"
"github.com/spf13/cobra"
)
var rootCmd = &cobra.Command{
Use: "asdf",
Short: "The multiple runtime version manager",
Long: `The Multiple Runtime Version Manager.
Manage all your runtime versions with one tool!
Complete documentation is available at https://asdf-vm.com/`,
Run: func(cmd *cobra.Command, args []string) {
// TODO: Flesh this out
fmt.Println("Late but latest -- Rajinikanth")
},
}
func init() {
// TODO: Add flags relevant to all commands
//rootCmd.PersistentFlags().BoolVarP(&Verbose, "verbose", "v", false, "verbose output")
// TODO: Add sub commands
//rootCmd.AddCommand(pluginCmd)
}
func Execute() {
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}

View File

@ -1,8 +1,10 @@
package main
import "fmt"
import (
"asdf/commands"
)
// Placeholder for the real code
func main() {
fmt.Println("Late but latest -- Rajinikanth")
commands.Execute()
}