mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-13 00:36:28 +00: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
|
doUpgradeCheck bool
|
||||||
upgradeTo string
|
upgradeTo string
|
||||||
noBrowser bool
|
noBrowser bool
|
||||||
|
browserOnly bool
|
||||||
noConsole bool
|
noConsole bool
|
||||||
logFile string
|
logFile string
|
||||||
auditEnabled bool
|
auditEnabled bool
|
||||||
@ -232,6 +233,7 @@ func main() {
|
|||||||
flag.StringVar(&confDir, "home", "", "Set configuration directory")
|
flag.StringVar(&confDir, "home", "", "Set configuration directory")
|
||||||
flag.IntVar(&logFlags, "logflags", logFlags, "Select information in log line prefix (see below)")
|
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(&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(&noRestart, "no-restart", noRestart, "Do not restart; just exit")
|
||||||
flag.BoolVar(&reset, "reset", false, "Reset the database")
|
flag.BoolVar(&reset, "reset", false, "Reset the database")
|
||||||
flag.BoolVar(&doUpgrade, "upgrade", false, "Perform upgrade")
|
flag.BoolVar(&doUpgrade, "upgrade", false, "Perform upgrade")
|
||||||
@ -282,6 +284,11 @@ func main() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if browserOnly {
|
||||||
|
openGUI()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
l.SetFlags(logFlags)
|
l.SetFlags(logFlags)
|
||||||
|
|
||||||
if generateDir != "" {
|
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) {
|
func generate(generateDir string) {
|
||||||
dir, err := osutil.ExpandTilde(generateDir)
|
dir, err := osutil.ExpandTilde(generateDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user