File: mclib.go

package info (click to toggle)
golang-github-bep-mclib 1.20400.20402-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 164 kB
  • sloc: makefile: 4
file content (42 lines) | stat: -rw-r--r-- 882 bytes parent folder | download
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()
}