2019-08-07 20:46:13 +00:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"github.com/drakkan/sftpgo/utils"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
logSender = "cmd"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
rootCmd = &cobra.Command{
|
|
|
|
Use: "sftpgo",
|
|
|
|
Short: "Full featured and highly configurable SFTP server",
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2019-08-08 08:01:33 +00:00
|
|
|
version := utils.GetAppVersion()
|
2019-08-07 20:46:13 +00:00
|
|
|
rootCmd.Flags().BoolP("version", "v", false, "")
|
2019-08-08 08:01:33 +00:00
|
|
|
rootCmd.Version = version.GetVersionAsString()
|
|
|
|
rootCmd.SetVersionTemplate(`{{printf "SFTPGo version: "}}{{printf "%s" .Version}}
|
2019-08-07 20:46:13 +00:00
|
|
|
`)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Execute adds all child commands to the root command and sets flags appropriately.
|
|
|
|
// This is called by main.main(). It only needs to happen once to the rootCmd.
|
|
|
|
func Execute() {
|
|
|
|
if err := rootCmd.Execute(); err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
}
|