Skip to content
This repository has been archived by the owner on Feb 18, 2023. It is now read-only.

Commit

Permalink
Add cli args support to automatically open dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
NGnius committed Sep 11, 2019
1 parent b64f0c2 commit 64ddc31
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
18 changes: 18 additions & 0 deletions rxsm/main-display.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,24 @@ func (d *Display) Run() {
d.installPathDialog.OpenInstallPathDialog()
}

if len(os.Args) > 1 {
switch os.Args[1] {
case "-settings", "--settings":
log.Println("Found -settings run arg, opening settingsDialog")
d.settingsButton.Click()
case "-install-path", "--install-path":
if d.installPathDialog == nil {
log.Println("Found -install-path run arg, opening installPathDialog")
d.installPathDialog = NewInstallPathDialog(d.window, 0)
d.installPathDialog.ConnectFinished(d.onInstallPathDialogFinished)
d.installPathDialog.OpenInstallPathDialog()
}
case "-versioning", "--versioning":
log.Println("Found -versions run arg, opening versionDialog")
d.versionsButton.Click()
}
}

// start the main Qt event loop
// and block until app.Exit() is called
// or the window is closed by the user
Expand Down
26 changes: 25 additions & 1 deletion rxsm/rxsm.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"log"
"runtime"
"strconv"
//"fmt"
"fmt"
)

const (
Expand Down Expand Up @@ -42,6 +42,10 @@ func init() {

func main() {
var exitVal int
shouldExit := parseRunArgs()
if shouldExit {
os.Exit(exitVal)
}
log.Println("Starting main routine")
GlobalConfig.Save()
log.Println("RobocraftX Play Path: "+GlobalConfig.PlayPath)
Expand All @@ -60,3 +64,23 @@ func main() {
log.Println("rxsm terminated")
os.Exit(exitVal) // this prevents defered operations, which may cause issues
}

func parseRunArgs() (exit bool) {
if len(os.Args) > 1 {
switch os.Args[1] {
case "-version", "--version", "version":
versionStr := "RXSM version "
if GlobalConfig.LastVersion() != GlobalConfig.Version {
if GlobalConfig.LastVersion() == "" {
versionStr += "unknown version -> "
} else {
versionStr += GlobalConfig.LastVersion()+" -> "
}
}
versionStr += GlobalConfig.Version
fmt.Println(versionStr)
exit = true
}
}
return
}

0 comments on commit 64ddc31

Please sign in to comment.