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) { }, PersistentPreRun: func(cmd *cobra.Command, args []string) { if flag.Value.Json { output.Current = &output.Json{} } else { output.Current = &output.Text{} } output.Current.SetCmd(cmd) cfg := &config{} if err := env.Parse(cfg); err != nil { panic(fmt.Sprintf("parse environment variables: %s", err.Error())) } server := &flag.Value.Server if cfg.NatsURL != "" { *server = cfg.NatsURL } vs := &flag.Value.Version if vs != nil && *vs { ctx := context.Background() shar := util.GetClient() conErr := shar.Dial(ctx, flag.Value.Server) 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"` } vinfo, err := shar.GetServerVersionInfo(ctx) if err == 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 { var e string if conErr != nil { e = conErr.Error() } else { e = err.Error() } 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: e, }, } 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.