diff --git a/build.sh b/build.sh index 4813981..8555b2d 100755 --- a/build.sh +++ b/build.sh @@ -15,6 +15,6 @@ for I in ${!OSLIST[*]}; do OUT=${OUT}.exe fi - go build -o $OUT + go build -o $OUT -ldflags "-X main.tag=$(git describe)" done done diff --git a/cli.go b/cli.go index 4166e0c..829a629 100644 --- a/cli.go +++ b/cli.go @@ -2,11 +2,13 @@ package main import ( "flag" + "fmt" ) func cli() { paths, names := getProfilePaths() + version := flag.Bool("version", false, "Shows the current version") uninstalling := flag.Bool("uninstall", false, "Wheter to install or uninstall ShadowFox") profileName := flag.String("profile-name", "", "Name of profile to use, if not defined or not found will fallback to profile-index") profileIndex := flag.Int("profile-index", 0, "Index of profile to use") @@ -15,6 +17,11 @@ func cli() { flag.Parse() + if *version { + fmt.Println(header) + return + } + var path string for i, name := range names { if name == *profileName { diff --git a/fallback.go b/fallback.go index 8d29e6d..559fbb0 100644 --- a/fallback.go +++ b/fallback.go @@ -6,6 +6,8 @@ import ( ) func createFallbackUI() { + fmt.Println(header) + var choice string paths, names := getProfilePaths() diff --git a/main.go b/main.go index 193176e..0974ca3 100644 --- a/main.go +++ b/main.go @@ -4,6 +4,9 @@ import ( "os" ) +var tag string +var header = "Shadowfox updater " + tag + func main() { if len(os.Args) > 1 { cli() diff --git a/ui.go b/ui.go index bb3a716..3908b8a 100644 --- a/ui.go +++ b/ui.go @@ -6,7 +6,7 @@ import ( func checkErr(msg string, err error) { if err != nil { - dlgs.Error("Shadowfox Updater", msg+"\n"+err.Error()) + dlgs.Error(header, msg+"\n"+err.Error()) panic(err) } } @@ -14,13 +14,13 @@ func checkErr(msg string, err error) { func createUI() error { paths, names := getProfilePaths() - name, selected, err := dlgs.List("Shadowfox Updater", "Which Firefox profile are you going to use?", names) + name, selected, err := dlgs.List(header, "Which Firefox profile are you going to use?", names) if err != nil { return err } if !selected { - _, err := dlgs.Info("Shadowfox Updater", "You didn't pick any profile, the application will now close.") + _, err := dlgs.Info(header, "You didn't pick any profile, the application will now close.") if err != nil { return err } @@ -36,30 +36,30 @@ func createUI() error { } profilePath := paths[pathIndex] - action, selected, err := dlgs.List("Shadowfox Updater", "What do you want to do?", []string{"Install/Update Shadowfox", "Uninstall Shadowfox"}) + action, selected, err := dlgs.List(header, "What do you want to do?", []string{"Install/Update Shadowfox", "Uninstall Shadowfox"}) if err != nil { return err } if !selected { - dlgs.Info("Shadowfox Updater", "You didn't pick any action, the application will now close.") + dlgs.Info(header, "You didn't pick any action, the application will now close.") return nil } if action == "Install/Update Shadowfox" { - shouldGenerateUUIDs, err := dlgs.Question("Shadowfox Updater", "Would you like to auto-generate UUIDs?", true) + shouldGenerateUUIDs, err := dlgs.Question(header, "Would you like to auto-generate UUIDs?", true) if err != nil { return err } - shouldSetTheme, err := dlgs.Question("Shadowfox Updater", "Would you like to automatically set the Firefox dark theme?", false) + shouldSetTheme, err := dlgs.Question(header, "Would you like to automatically set the Firefox dark theme?", false) if err != nil { return err } msg, err := install(profilePath, shouldGenerateUUIDs, shouldSetTheme) if err == nil { - _, err = dlgs.Info("Shadowfox Updater", "Shadowfox has been succesfully installed!") + _, err = dlgs.Info(header, "Shadowfox has been succesfully installed!") if err != nil { return err } @@ -69,7 +69,7 @@ func createUI() error { } else { msg, err := uninstall(profilePath) if err == nil { - _, err = dlgs.Info("Shadowfox Updater", "Shadowfox has been succesfully uninstalled!") + _, err = dlgs.Info(header, "Shadowfox has been succesfully uninstalled!") if err != nil { return err }