mirror of
https://github.com/spf13/cobra
synced 2024-11-24 22:57:12 +00:00
Add EnableWindowsMouseTrap variable again (removed in commit 193b182195
)
This commit is contained in:
parent
1dd5ff2e11
commit
a25becd535
2 changed files with 9 additions and 4 deletions
3
cobra.go
3
cobra.go
|
@ -45,6 +45,9 @@ var EnablePrefixMatching = false
|
|||
// To disable sorting, set it to false.
|
||||
var EnableCommandSorting = true
|
||||
|
||||
// EnableWindowsMouseTrap enables an information splash screen on Windows if the CLI is started from explorer.exe.
|
||||
var EnableWindowsMouseTrap = true
|
||||
|
||||
// AddTemplateFunc adds a template function that's available to Usage and Help
|
||||
// template generation.
|
||||
func AddTemplateFunc(name string, tmplFunc interface{}) {
|
||||
|
|
|
@ -18,9 +18,11 @@ You need to open cmd.exe and run it from there.
|
|||
`
|
||||
|
||||
func preExecHook(c *Command) {
|
||||
if mousetrap.StartedByExplorer() {
|
||||
c.Print(MousetrapHelpText)
|
||||
time.Sleep(5 * time.Second)
|
||||
os.Exit(1)
|
||||
if EnableWindowsMouseTrap {
|
||||
if mousetrap.StartedByExplorer() {
|
||||
c.Print(MousetrapHelpText)
|
||||
time.Sleep(5 * time.Second)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue