31d285813e
we try to remove the trailing double quote for user input such as this one sftpgo.exe serve -c "C:\ProgramData\SFTPGO\" the value for the -c flag is parsed as: C:\ProgramData\SFTPGO" this is what the user specified, but the user want this value: C:\ProgramData\SFTPGO so we try to remove the trailing double quote. Please note that we cannot do anything for something like this: -c "C:\ProgramData\SFTPGO\" -l "sftpgo.log" in this case the -l flag will be ignored and the value for the c flag is: C:\ProgramData\SFTPGO" -l sftpgo.log and so probably it is invalid. This is definitely a bad user input
40 lines
931 B
Go
40 lines
931 B
Go
package cmd
|
|
|
|
import (
|
|
"github.com/drakkan/sftpgo/service"
|
|
"github.com/drakkan/sftpgo/utils"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var (
|
|
serveCmd = &cobra.Command{
|
|
Use: "serve",
|
|
Short: "Start the SFTP Server",
|
|
Long: `To start the SFTPGo with the default values for the command line flags simply use:
|
|
|
|
sftpgo serve
|
|
|
|
Please take a look at the usage below to customize the startup options`,
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
service := service.Service{
|
|
ConfigDir: utils.CleanDirInput(configDir),
|
|
ConfigFile: configFile,
|
|
LogFilePath: logFilePath,
|
|
LogMaxSize: logMaxSize,
|
|
LogMaxBackups: logMaxBackups,
|
|
LogMaxAge: logMaxAge,
|
|
LogCompress: logCompress,
|
|
LogVerbose: logVerbose,
|
|
Shutdown: make(chan bool),
|
|
}
|
|
if err := service.Start(); err == nil {
|
|
service.Wait()
|
|
}
|
|
},
|
|
}
|
|
)
|
|
|
|
func init() {
|
|
rootCmd.AddCommand(serveCmd)
|
|
addServeFlags(serveCmd)
|
|
}
|