Skip to content

Commit

Permalink
feat: open desktop mode by default
Browse files Browse the repository at this point in the history
  • Loading branch information
evan-buss committed Jun 15, 2022
1 parent 9ec5a10 commit a723021
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 8 additions & 0 deletions cmd/openbooks/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ var rootCmd = &cobra.Command{
}

func main() {
// Open in desktop mode by default (no arguments / double click)
cmd, _, err := rootCmd.Find(os.Args[1:])
if err != nil || cmd == nil || cmd.Name() == rootCmd.Name() {
// Not found
args := append([]string{"desktop"}, os.Args[1:]...)
rootCmd.SetArgs(args)
}

if err := rootCmd.Execute(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
Expand Down
2 changes: 0 additions & 2 deletions cmd/openbooks/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ var desktopCmd = &cobra.Command{
}

func bindGlobalFlags() {
fmt.Println("Binding global flags...")
serverConfig.Version = fmt.Sprintf("OpenBooks Server %s", ircVersion)
serverConfig.UserName = globalFlags.UserName
serverConfig.DownloadDir = globalFlags.DownloadDir
Expand All @@ -81,7 +80,6 @@ func bindGlobalFlags() {
}

func ensureValidRate(cmd *cobra.Command) {
fmt.Println("Validating flags...")
rateLimit, _ := cmd.Flags().GetInt("rate-limit")

// If user enters a limit that's too low, set to default of 10 seconds.
Expand Down

0 comments on commit a723021

Please sign in to comment.