version.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright © 2019 - 2020 Oscar Campos <oscar.campos@thepimpam.com>
  2. // Copyright © 2017 - William Edwards
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License
  15. package main
  16. import (
  17. "fmt"
  18. "os"
  19. "path/filepath"
  20. )
  21. const unknown string = "unknown"
  22. var (
  23. version = unknown
  24. commit = unknown
  25. date = unknown
  26. builtBy = unknown
  27. )
  28. type versionCmd struct{}
  29. func (cmd *versionCmd) Run(ctx *context) error {
  30. appName := filepath.Base(os.Args[0])
  31. fmt.Printf(
  32. "%s %s-%s\n\tbuilt on: %s\n\tbuilt by: %s\n",
  33. appName, version, commit, date, builtBy,
  34. )
  35. return nil
  36. }