Skip to content

Commit 13dfd92

Browse files
authored
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
1 parent 84f5382 commit 13dfd92

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

interfacer/src/browsh/browsh.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,20 @@ func MainEntry() {
204204
}
205205
viper.SetDefault("validURL", validURL)
206206
Initialise()
207-
if viper.GetBool("version") {
207+
208+
// Print version if asked and exit
209+
if (viper.GetBool("version") || viper.GetBool("v")) {
208210
println(browshVersion)
209211
os.Exit(0)
210212
}
213+
214+
// Print name if asked and exit
215+
if (viper.GetBool("name") || viper.GetBool("n")) {
216+
println("Browsh")
217+
os.Exit(0)
218+
}
219+
220+
// Decide whether to run in http-server-mode or CLI app
211221
if viper.GetBool("http-server-mode") {
212222
HTTPServerStart()
213223
} else {

interfacer/src/browsh/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ var (
2424
_ = pflag.Bool("firefox.with-gui", false, "Don't use headless Firefox")
2525
_ = pflag.Bool("firefox.use-existing", false, "Whether Browsh should launch Firefox or not")
2626
_ = pflag.Bool("monochrome", false, "Start browsh in monochrome mode")
27+
_ = pflag.Bool("name", false, "Print out the name: Browsh")
2728
)
2829

2930
func getConfigNamespace() string {

0 commit comments

Comments
 (0)