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
This commit is contained in:
Yash Singh 2020-08-21 01:44:26 -07:00 committed by GitHub
parent 84f5382eda
commit 13dfd9288a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -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 {

View File

@ -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 {