func printUsage() { fmt.Printf("gauge -version %s\n", version.FullVersion()) fmt.Printf("Copyright %d ThoughtWorks, Inc.\n\n", time.Now().Year()) fmt.Println("Usage:") fmt.Println("\tgauge specs/") fmt.Println("\tgauge specs/spec_name.spec") fmt.Println("\nOptions:") flag.PrintDefaults() }
func printVersion() { fmt.Printf("Gauge version: %s\n\n", version.FullVersion()) fmt.Println("Plugins\n-------") allPluginsWithVersion, err := plugin.GetAllInstalledPluginsWithVersion() if err != nil { fmt.Println("No plugins found") fmt.Println("Plugins can be installed with `gauge --install {plugin-name}`") os.Exit(0) } for _, pluginInfo := range allPluginsWithVersion { fmt.Printf("%s (%s)\n", pluginInfo.Name, filepath.Base(pluginInfo.Path)) } }
func printJSONVersion() { type pluginJSON struct { Name string `json:"name"` Version string `json:"version"` } type versionJSON struct { Version string `json:"version"` Plugins []*pluginJSON `json:"plugins"` } gaugeVersion := versionJSON{version.FullVersion(), make([]*pluginJSON, 0)} allPluginsWithVersion, err := plugin.GetAllInstalledPluginsWithVersion() for _, pluginInfo := range allPluginsWithVersion { gaugeVersion.Plugins = append(gaugeVersion.Plugins, &pluginJSON{pluginInfo.Name, filepath.Base(pluginInfo.Path)}) } b, err := json.MarshalIndent(gaugeVersion, "", " ") if err != nil { fmt.Println("error:", err) } fmt.Println(fmt.Sprintf("%s\n", string(b))) }