generated from bep/golibtemplate
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
mclib.go
42 lines (36 loc) · 882 Bytes
/
mclib.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package mclib
import (
"fmt"
"os"
"strings"
"github.com/bep/mclib/internal"
)
var errorReplacer = strings.NewReplacer(
"ERROR: ", "",
)
// RunMain runs mkcert's main function.
//
// You need to set os.Args before calling this function, e.g.
//
// os.Args = []string{"-install"}
// os.Args = []string{"-cert-file", "cert.pem", "-key-file", "key.pem", "example.com"}
func RunMain() (err error) {
defer func() {
if r := recover(); r != nil {
errStr := fmt.Sprintf("%v", r)
errStr = errorReplacer.Replace(errStr)
err = fmt.Errorf(errStr)
}
}()
const mkcert = "mkcert"
if len(os.Args) == 0 || os.Args[0] != mkcert {
// All commands needs the "mkcert" as its first argument.
os.Args = append([]string{mkcert}, os.Args...)
}
internal.RunMain()
return
}
// GetCAROOT returns the CA root directory.
func GetCAROOT() string {
return internal.GetCAROOT()
}