Clone this repo:
  1. 4e8053e Merge pull request #7 from thaJeztah/remove_go1.4 by Alan Shreve · 1 year, 6 months ago master v1.1 v1.1.0
  2. 15567a6 remove "os" import by Sebastiaan van Stijn · 1 year, 7 months ago
  3. 109353e rename files to regular name, and update buildtags by Sebastiaan van Stijn · 1 year, 7 months ago
  4. 163230f remove support for go1.3 by Sebastiaan van Stijn · 1 year, 7 months ago
  5. 3a66f25 add go.mod by Alan Shreve · 1 year, 10 months ago v1.0.1

mousetrap

mousetrap is a tiny library that answers a single question.

On a Windows machine, was the process invoked by someone double clicking on the executable file while browsing in explorer?

Motivation

Windows developers unfamiliar with command line tools will often “double-click” the executable for a tool. Because most CLI tools print the help and then exit when invoked without arguments, this is often very frustrating for those users.

mousetrap provides a way to detect these invocations so that you can provide more helpful behavior and instructions on how to run the CLI tool. To see what this looks like, both from an organizational and a technical perspective, see https://inconshreveable.com/09-09-2014/sweat-the-small-stuff/

The interface

The library exposes a single interface:

func StartedByExplorer() (bool)