mirror of
https://github.com/syncthing/syncthing.git
synced 2024-11-16 10:28:49 -07:00
Add command line option to open GUI (fixes #2210)
--browser-only assumes syncthing is already running and will open the user's browser in the URL:port currently used in the configuration if the GUI is enabled.
This commit is contained in:
parent
6379d50f07
commit
5cf15db6e4
@ -198,6 +198,7 @@ var (
|
||||
doUpgradeCheck bool
|
||||
upgradeTo string
|
||||
noBrowser bool
|
||||
browserOnly bool
|
||||
noConsole bool
|
||||
logFile string
|
||||
auditEnabled bool
|
||||
@ -232,6 +233,7 @@ func main() {
|
||||
flag.StringVar(&confDir, "home", "", "Set configuration directory")
|
||||
flag.IntVar(&logFlags, "logflags", logFlags, "Select information in log line prefix (see below)")
|
||||
flag.BoolVar(&noBrowser, "no-browser", false, "Do not start browser")
|
||||
flag.BoolVar(&browserOnly, "browser-only", false, "Open GUI in browser")
|
||||
flag.BoolVar(&noRestart, "no-restart", noRestart, "Do not restart; just exit")
|
||||
flag.BoolVar(&reset, "reset", false, "Reset the database")
|
||||
flag.BoolVar(&doUpgrade, "upgrade", false, "Perform upgrade")
|
||||
@ -282,6 +284,11 @@ func main() {
|
||||
return
|
||||
}
|
||||
|
||||
if browserOnly {
|
||||
openGUI()
|
||||
return
|
||||
}
|
||||
|
||||
l.SetFlags(logFlags)
|
||||
|
||||
if generateDir != "" {
|
||||
@ -357,6 +364,18 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
func openGUI() {
|
||||
cfg, _, err := loadConfig(locations[locConfigFile])
|
||||
if err != nil {
|
||||
l.Fatalln("Config:", err)
|
||||
}
|
||||
if cfg.GUI().Enabled {
|
||||
openURL(cfg.GUI().URL())
|
||||
} else {
|
||||
l.Warnln("Browser: GUI is currently disabled")
|
||||
}
|
||||
}
|
||||
|
||||
func generate(generateDir string) {
|
||||
dir, err := osutil.ExpandTilde(generateDir)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user