feat: Add version print

This commit is contained in:
Muyao CHEN
2024-10-02 22:21:09 +02:00
parent 08e2d6bd4a
commit 62597e4534
7 changed files with 185 additions and 2 deletions

View File

@ -28,6 +28,7 @@ import (
"net/http"
"git.vinchent.xyz/vinchent/howmuch/internal/pkg/log"
"git.vinchent.xyz/vinchent/howmuch/pkg/version/verflag"
"github.com/fsnotify/fsnotify"
"github.com/gin-gonic/gin"
"github.com/spf13/cobra"
@ -48,6 +49,9 @@ func NewHowMuchCommand() *cobra.Command {
Long: `howmuch is a expense-sharing application that can help friends
to share their expense of an event or a trip`,
RunE: func(cmd *cobra.Command, args []string) error {
// print version and exit?
verflag.PrintVersion()
// init log
log.Init(logOptions())
// Sync flush the buffer
@ -78,6 +82,9 @@ to share their expense of an event or a trip`,
// when this action is called directly.
rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
// --version
verflag.AddFlags(rootCmd.PersistentFlags())
return rootCmd
}