cmd/syncthing: Add debug commands to cli (#7503)

This commit is contained in:
Simon Frei
2021-04-22 11:14:25 +02:00
committed by GitHub
parent 59bdcdabba
commit 54e27f551d
15 changed files with 277 additions and 188 deletions
+2 -18
View File
@@ -34,6 +34,7 @@ import (
"github.com/thejerf/suture/v4"
"github.com/syncthing/syncthing/cmd/syncthing/cli"
"github.com/syncthing/syncthing/cmd/syncthing/cmdutil"
"github.com/syncthing/syncthing/cmd/syncthing/decrypt"
"github.com/syncthing/syncthing/lib/build"
"github.com/syncthing/syncthing/lib/config"
@@ -290,24 +291,7 @@ func (options serveOptions) Run() error {
}
// Not set as default above because the strings can be really long.
var err error
homeSet := options.HomeDir != ""
confSet := options.ConfDir != ""
dataSet := options.DataDir != ""
switch {
case dataSet != confSet:
err = errors.New("either both or none of -conf and -data must be given, use -home to set both at once")
case homeSet && dataSet:
err = errors.New("-home must not be used together with -conf and -data")
case homeSet:
if err = locations.SetBaseDir(locations.ConfigBaseDir, options.HomeDir); err == nil {
err = locations.SetBaseDir(locations.DataBaseDir, options.HomeDir)
}
case dataSet:
if err = locations.SetBaseDir(locations.ConfigBaseDir, options.ConfDir); err == nil {
err = locations.SetBaseDir(locations.DataBaseDir, options.DataDir)
}
}
err := cmdutil.SetConfigDataLocationsFromFlags(options.HomeDir, options.ConfDir, options.DataDir)
if err != nil {
l.Warnln("Command line options:", err)
os.Exit(svcutil.ExitError.AsInt())