From ff040aa1bddda2b4531460a37e49a32cbca52585 Mon Sep 17 00:00:00 2001 From: Trevor Brown Date: Wed, 21 Feb 2024 20:19:38 -0500 Subject: [PATCH] feat(golang-rewrite): update cmd code to use urfave/cli --- cmd/main.go | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 8fb9673a..03f0b8ea 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -1,37 +1,33 @@ package cmd import ( - "fmt" + "log" "os" - "github.com/spf13/cobra" + "github.com/urfave/cli/v2" ) -var rootCmd = &cobra.Command{ - Use: "asdf", - Short: "The multiple runtime version manager", - Long: `The Multiple Runtime Version Manager. +func Execute() { + app := &cli.App{ + Name: "asdf", + Version: "0.1.0", + Usage: "The multiple runtime version manager", + UsageText: `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") + Action: func(cCtx *cli.Context) error { + // TODO: flesh this out + log.Print("Late but latest -- Rajinikanth") + return nil + }, + } - // TODO: Add sub commands - //rootCmd.AddCommand(pluginCmd) -} + err := app.Run(os.Args) -func Execute() { - if err := rootCmd.Execute(); err != nil { - fmt.Println(err) + if err != nil { os.Exit(1) + log.Fatal(err) } }