version.go 803 B

1234567891011121314151617181920212223242526272829303132333435
  1. // Package version implements the version command.
  2. package version
  3. import (
  4. "fmt"
  5. "runtime"
  6. "github.com/cloudflare/cfssl/cli"
  7. )
  8. var (
  9. version = "dev"
  10. )
  11. // Usage text for 'cfssl version'
  12. var versionUsageText = `cfssl version -- print out the version of CF SSL
  13. Usage of version:
  14. cfssl version
  15. `
  16. // FormatVersion returns the formatted version string.
  17. func FormatVersion() string {
  18. return fmt.Sprintf("Version: %s\nRuntime: %s\n", version, runtime.Version())
  19. }
  20. // The main functionality of 'cfssl version' is to print out the version info.
  21. func versionMain(args []string, c cli.Config) (err error) {
  22. fmt.Printf("%s", FormatVersion())
  23. return nil
  24. }
  25. // Command assembles the definition of Command 'version'
  26. var Command = &cli.Command{UsageText: versionUsageText, Flags: nil, Main: versionMain}