cdglab/main.go
cdryzun 209dd37cc1
All checks were successful
Release / release (push) Successful in 5m56s
add version
2023-12-23 22:21:42 +08:00

57 lines
1.3 KiB
Go

package main
import (
"fmt"
"os"
cmd "git.treesir.pub/cdryzun/cdglab/cmd"
"github.com/spf13/cobra"
goVersion "go.hein.dev/go-version"
)
var (
shortened = false
version = "dev"
commit = "none"
date = "unknown"
output = "json"
versionCmd = &cobra.Command{
Use: "version",
Short: "Version will output the current build information",
Long: ``,
Run: func(_ *cobra.Command, _ []string) {
resp := goVersion.FuncWithOutput(shortened, version, commit, date, output)
fmt.Print(resp)
},
}
)
var rootCmd = &cobra.Command{
Use: "cdglab",
Short: "cdglab is a tool for gitlab CI-CD.",
Long: `cdglab is a basic tool for Gitlab CI/CD, used to encapsulate a series of RESTful API calls.`,
// Version: "v0.0.1",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("Execute the command cdglab -h to view the usage method.")
},
}
func init() {
rootCmd.AddCommand()
rootCmd.AddCommand(cmd.RawCmd)
rootCmd.AddCommand(versionCmd)
versionCmd.Flags().BoolVarP(&shortened, "short", "s", false, "Print just the version number.")
versionCmd.Flags().StringVarP(&output, "output", "o", "json", "Output format. One of 'yaml' or 'json'.")
}
func Execute() {
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}
func main() {
Execute()
}