Esempio n. 1
0
func printVersionCmd(c *cli.Context) error {
	fullVersion := c.Bool("full")

	if err := output.ConfigureOutputFormat(c); err != nil {
		log.Fatalf("Failed to configure output format, error: %s", err)
	}

	versionOutput := VersionOutputModel{
		Version: version.VERSION,
	}

	if fullVersion {
		versionOutput.FormatVersion = models.Version
		versionOutput.BuildNumber = version.BuildNumber
		versionOutput.Commit = version.Commit
	}

	if output.Format == output.FormatRaw {
		if fullVersion {
			fmt.Fprintf(c.App.Writer, "version: %v\nformat version: %v\nbuild number: %v\ncommit: %v\n", versionOutput.Version, versionOutput.FormatVersion, versionOutput.BuildNumber, versionOutput.Commit)
		} else {
			fmt.Fprintf(c.App.Writer, "%v\n", versionOutput.Version)
		}
	} else {
		output.Print(versionOutput, output.Format)
	}

	return nil
}
Esempio n. 2
0
func printVersionCmd(c *cli.Context) {
	if err := configs.ConfigureOutputFormat(c); err != nil {
		log.Fatalf("Error: %s", err)
	}

	if configs.OutputFormat == configs.OutputFormatRaw {
		fmt.Fprintf(c.App.Writer, "%v\n", c.App.Version)
	} else {
		output.Print(VersionOutputModel{c.App.Version}, configs.OutputFormat)
	}
}
Esempio n. 3
0
func printVersionCmd(c *cli.Context) error {
	fullVersion := c.Bool("full")

	if err := output.ConfigureOutputFormat(c); err != nil {
		log.Fatalf("Failed to configure output format, error: %s", err)
	}

	versionOutput := VersionOutputModel{
		Version: version.VERSION,
	}

	if fullVersion {
		versionOutput.FormatVersion = models.Version
		versionOutput.BuildNumber = version.BuildNumber
		versionOutput.Commit = version.Commit
		versionOutput.OS = fmt.Sprintf("%s (%s)", runtime.GOOS, runtime.GOARCH)
		versionOutput.GO = runtime.Version()
	}

	if output.Format == output.FormatRaw {
		if fullVersion {
			versionStr := fmt.Sprintf(`version: %s
format version: %s
os: %s
go: %s
build number: %s
commit: %s
`, versionOutput.Version, versionOutput.FormatVersion, versionOutput.OS, versionOutput.GO, versionOutput.BuildNumber, versionOutput.Commit)
			fmt.Println(versionStr)
		} else {
			versionStr := fmt.Sprintf("%s", versionOutput.Version)
			fmt.Println(versionStr)
		}
	} else {
		output.Print(versionOutput, output.Format)
	}

	return nil
}