Skip to content

Commit

Permalink
Add command line option to open GUI (fixes #2210)
Browse files Browse the repository at this point in the history
--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.
  • Loading branch information
andersonvom committed Dec 16, 2015
1 parent 6379d50 commit 5cf15db
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions cmd/syncthing/main.go
Expand Up @@ -198,6 +198,7 @@ var (
doUpgradeCheck bool
upgradeTo string
noBrowser bool
browserOnly bool
noConsole bool
logFile string
auditEnabled bool
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -282,6 +284,11 @@ func main() {
return
}

if browserOnly {
openGUI()
return
}

l.SetFlags(logFlags)

if generateDir != "" {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 5cf15db

Please sign in to comment.