You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been wracking my brain, trying to figure out why my windows application won't launch from a double-click.
I'm using Pocketbase, and I isolated it to Pocketbase's Start command.
After digging in deep, I discovered that Pocketbase relies on Cobra, which has a "mousetrap" in place to prevent it from being used from a double-click... because it's a CLI tool and the authors don't want people to accidentally launch Cobra apps from a double-click.
Here's the repaired, working code. The relevant line is cobra.MousetrapHelpText = "". I imported "github.com/spf13/cobra" and set it on the imported module.
func StartPocketbase() *pocketbase.PocketBase {
configDir, err := os.UserConfigDir()
if err != nil {
log.Fatal(err)
}
dataDir := filepath.Join(configDir, "QuiverPhotos", "__data")
EnsurePathExists(dataDir)
publicDir := filepath.Join(configDir, "QuiverPhotos", "__public")
EnsurePathExists(publicDir)
isDev := strings.Contains(os.Args[0], "-dev-")
os.Args = []string{"pocketbase", "serve", "--dir=" + dataDir, "--publicDir=" + publicDir}
app := pocketbase.New()
if isDev {
fmt.Println("🤖 Starting pocketbase in dev mode...")
}
migratecmd.MustRegister(app, app.RootCmd, migratecmd.Config{
Automigrate: isDev,
})
go func() {
cobra.MousetrapHelpText = "" // Disable the mousetrap help text
err := app.Start()
log.Println("app.Start err:", err)
if err != nil {
log.Println("Failed to start pocketbase:", err)
}
}()
return app
}
The text was updated successfully, but these errors were encountered:
Double clicking will not work because we don't register a default command, aka. it is expected users to invoke the .\pocketbase serve command from the terminal.
Unless I'm misunderstand something there no plans for now to change this as I already have enough on my hands (see #4355).
edit: On second read I see that you are registering your own custom Start action. But in any case if you have other questions or just want to share something with the community, please consider using the Discussions instead.
FOR POSTERITY
I've been wracking my brain, trying to figure out why my windows application won't launch from a double-click.
I'm using Pocketbase, and I isolated it to Pocketbase's
Start
command.After digging in deep, I discovered that Pocketbase relies on Cobra, which has a "mousetrap" in place to prevent it from being used from a double-click... because it's a CLI tool and the authors don't want people to accidentally launch Cobra apps from a double-click.
Here's the repaired, working code. The relevant line is
cobra.MousetrapHelpText = ""
. I imported"github.com/spf13/cobra"
and set it on the imported module.The text was updated successfully, but these errors were encountered: