mirror of
https://github.com/project-zot/zot.git
synced 2026-06-17 21:17:58 +08:00
b1842ab9e0
* fix: migrate from github.com/rs/zerolog to golang-native log/slog We have been using zerolog for a really long time. golang now has structured logging using slog. Best to move to this in interests of long-term support. This is a tech debt item. Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com> * fix: a few changes on top Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com> * fix: address comments Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com> --------- Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
43 lines
961 B
Go
43 lines
961 B
Go
//go:build search
|
|
// +build search
|
|
|
|
package client
|
|
|
|
import (
|
|
distspec "github.com/opencontainers/distribution-spec/specs-go"
|
|
"github.com/spf13/cobra"
|
|
|
|
"zotregistry.dev/zot/pkg/api/config"
|
|
"zotregistry.dev/zot/pkg/log"
|
|
)
|
|
|
|
// "zli" - client-side cli.
|
|
func NewCliRootCmd() *cobra.Command {
|
|
showVersion := false
|
|
|
|
rootCmd := &cobra.Command{
|
|
Use: "zli",
|
|
Short: "`zli`",
|
|
Long: "`zli`",
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
if showVersion {
|
|
logger := log.NewLogger("info", "")
|
|
logger.Info().Str("distribution-spec", distspec.Version).Str("commit", config.Commit).
|
|
Str("binary-type", config.BinaryType).Str("go version", config.GoVersion).Msg("version")
|
|
} else {
|
|
_ = cmd.Usage()
|
|
cmd.SilenceErrors = false
|
|
}
|
|
},
|
|
}
|
|
|
|
rootCmd.SilenceUsage = true
|
|
|
|
// additional cmds
|
|
enableCli(rootCmd)
|
|
// "version"
|
|
rootCmd.Flags().BoolVarP(&showVersion, VersionFlag, "v", false, "show the version and exit")
|
|
|
|
return rootCmd
|
|
}
|