mirror of
https://github.com/project-zot/zot.git
synced 2026-06-17 04:48:26 +08:00
refactor: Reduce zli binary size (#1805)
Signed-off-by: Alexei Dodon <adodon@cisco.com>
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
//go:build search
|
||||
// +build search
|
||||
|
||||
package client
|
||||
|
||||
import (
|
||||
distspec "github.com/opencontainers/distribution-spec/specs-go"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"zotregistry.io/zot/pkg/api/config"
|
||||
"zotregistry.io/zot/pkg/cli/cmdflags"
|
||||
)
|
||||
|
||||
// "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 {
|
||||
log.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, cmdflags.VersionFlag, "v", false, "show the version and exit")
|
||||
|
||||
return rootCmd
|
||||
}
|
||||
Reference in New Issue
Block a user