root.go 704 B

123456789101112131415161718192021222324252627282930313233343536
  1. package cmd
  2. import (
  3. "fmt"
  4. "os"
  5. "github.com/drakkan/sftpgo/utils"
  6. "github.com/spf13/cobra"
  7. )
  8. const (
  9. logSender = "cmd"
  10. )
  11. var (
  12. rootCmd = &cobra.Command{
  13. Use: "sftpgo",
  14. Short: "Full featured and highly configurable SFTP server",
  15. }
  16. )
  17. func init() {
  18. rootCmd.Flags().BoolP("version", "v", false, "")
  19. rootCmd.Version = utils.GetAppVersion()
  20. rootCmd.SetVersionTemplate(`{{printf "SFTPGo version "}}{{printf "%s" .Version}}
  21. `)
  22. }
  23. // Execute adds all child commands to the root command and sets flags appropriately.
  24. // This is called by main.main(). It only needs to happen once to the rootCmd.
  25. func Execute() {
  26. if err := rootCmd.Execute(); err != nil {
  27. fmt.Println(err)
  28. os.Exit(1)
  29. }
  30. }