From 13dfd9288a5e548582d7f54112aa1ee6531fe891 Mon Sep 17 00:00:00 2001 From: Yash Singh <53054099+Yash-Singh1@users.noreply.github.com> Date: Fri, 21 Aug 2020 01:44:26 -0700 Subject: [PATCH] Improved CLI's flags and changed help page (#341) * Improved CLI's flags Allowed users to use just --v instead of --version as a CLI flag. Also added in the --name flag that simply prints out "Browsh." An alias for the --name flag is --n. * Changed the help page inside the config.go to include the name flag --- interfacer/src/browsh/browsh.go | 12 +++++++++++- interfacer/src/browsh/config.go | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/interfacer/src/browsh/browsh.go b/interfacer/src/browsh/browsh.go index d3f2dc5f..f6f24866 100644 --- a/interfacer/src/browsh/browsh.go +++ b/interfacer/src/browsh/browsh.go @@ -204,10 +204,20 @@ func MainEntry() { } viper.SetDefault("validURL", validURL) Initialise() - if viper.GetBool("version") { + + // Print version if asked and exit + if (viper.GetBool("version") || viper.GetBool("v")) { println(browshVersion) os.Exit(0) } + + // Print name if asked and exit + if (viper.GetBool("name") || viper.GetBool("n")) { + println("Browsh") + os.Exit(0) + } + + // Decide whether to run in http-server-mode or CLI app if viper.GetBool("http-server-mode") { HTTPServerStart() } else { diff --git a/interfacer/src/browsh/config.go b/interfacer/src/browsh/config.go index 81f56ebc..7a108bdc 100644 --- a/interfacer/src/browsh/config.go +++ b/interfacer/src/browsh/config.go @@ -24,6 +24,7 @@ var ( _ = pflag.Bool("firefox.with-gui", false, "Don't use headless Firefox") _ = pflag.Bool("firefox.use-existing", false, "Whether Browsh should launch Firefox or not") _ = pflag.Bool("monochrome", false, "Start browsh in monochrome mode") + _ = pflag.Bool("name", false, "Print out the name: Browsh") ) func getConfigNamespace() string {