Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var RootCmd = &cobra.Command{ Use: "shar", Short: "SHAR command line application " + version.Version, Long: ``, Run: func(cmd *cobra.Command, args []string) { if !flag.Value.Version { err := cmd.Help() if err != nil { panic(err) } } }, PersistentPreRun: func(cmd *cobra.Command, args []string) { if flag.Value.Json { output.Current = &output.Json{} } else { output.Current = &output.Text{} } output.Current.SetCmd(cmd) config.LoadSettings() vs := &flag.Value.Version if vs != nil && *vs { ctx := context.Background() shar, conErr := util.GetClient(ctx) type VersionInfo struct { Version string `json:"version,omitempty"` CompatibleVersion string `json:"compatible-version,omitempty"` NatsServer string `json:"tested-against-nats-server,omitempty"` NatsClient string `json:"tested-against-nats-client,omitempty"` Go string `json:"compiled-with,omitempty"` Error string `json:"error,omitempty"` } var vinfo *model.GetVersionInfoResponse if conErr == nil { vinfo, conErr = shar.GetServerVersionInfo(ctx) } if conErr == nil { v := &struct { Client VersionInfo `json:"client"` Server VersionInfo `json:"server"` }{ Client: VersionInfo{ Version: version.Version, NatsServer: version.NatsServerVersion, NatsClient: version.NatsGoVersion, Go: runtime.Version(), }, Server: VersionInfo{ Version: vinfo.ServerVersion, CompatibleVersion: vinfo.MinCompatibleVersion, NatsServer: vinfo.NatsServerVersion, NatsClient: vinfo.NatsClientVersion, Go: vinfo.GoVersion, }, } output.Current.Output(v) } else { v := &struct { Client VersionInfo `json:"client"` Server VersionInfo `json:"server"` }{ Client: VersionInfo{ Version: version.Version, NatsServer: version.NatsServerVersion, NatsClient: version.NatsGoVersion, Go: runtime.Version(), }, Server: VersionInfo{ Error: conErr.Error(), }, } output.Current.Output(v) } } }, }
RootCmd represents the base command when called without any subcommands
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.