From c3bf865b0ccc632ead5fdca30f0839a6f90ae7b1 Mon Sep 17 00:00:00 2001 From: Filippo Valsorda Date: Sat, 7 Jul 2018 00:07:41 -0400 Subject: [PATCH] Show custom usage on -help --- main.go | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/main.go b/main.go index d11400e..90747a9 100644 --- a/main.go +++ b/main.go @@ -20,11 +20,33 @@ import ( "golang.org/x/net/idna" ) +const usage = `Usage of mkcert: + + $ mkcert -install + Install the local CA in the system trust store. + + $ mkcert example.org + Generate "example.org.pem" and "example.org-key.pem". + + $ mkcert example.com myapp.dev localhost 127.0.0.1 ::1 + Generate "example.com+4.pem" and "example.com+4-key.pem". + + $ mkcert '*.example.com' + Generate "_wildcard.example.com.pem" and "_wildcard.example.com-key.pem". + + $ mkcert -uninstall + Uninstall the local CA (but do not delete it). + +Change the CA certificate and key storage location by setting $CAROOT, +print it with "mkcert -CAROOT". +` + func main() { log.SetFlags(0) var installFlag = flag.Bool("install", false, "install the local root CA in the system trust store") var uninstallFlag = flag.Bool("uninstall", false, "uninstall the local root CA from the system trust store") var carootFlag = flag.Bool("CAROOT", false, "print the CAROOT path") + flag.Usage = func() { fmt.Fprintf(flag.CommandLine.Output(), usage) } flag.Parse() if *carootFlag { if *installFlag || *uninstallFlag { @@ -89,27 +111,7 @@ func (m *mkcert) Run(args []string) { } if len(args) == 0 { - log.Printf(` -Usage: - - $ mkcert -install - Install the local CA in the system trust store. - - $ mkcert example.org - Generate "example.org.pem" and "example.org-key.pem". - - $ mkcert example.com myapp.dev localhost 127.0.0.1 ::1 - Generate "example.com+4.pem" and "example.com+4-key.pem". - - $ mkcert '*.example.com' - Generate "_wildcard.example.com.pem" and "_wildcard.example.com-key.pem". - - $ mkcert -uninstall - Uninstall the local CA (but do not delete it). - -Change the CA certificate and key storage location by setting $CAROOT, -print it with "mkcert -CAROOT". -`) + log.Printf("\n%s", usage) return }