-
Notifications
You must be signed in to change notification settings - Fork 3
/
darkness.go
45 lines (37 loc) · 1 KB
/
darkness.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
43
44
45
package main
import (
"fmt"
"os"
"github.com/pkg/profile"
"github.com/thecsw/darkness/v3/ichika"
)
const (
ProfileCpu = false
ProfileMem = false
ProfileClock = false
)
// main is the entry point for the program.
func main() {
// debug.SetGCPercent(-1)
// debug.SetMemoryLimit(math.MaxInt64)
if ProfileCpu {
defer profile.Start(profile.CPUProfile, profile.ProfilePath(".")).Stop()
} else if ProfileMem {
defer profile.Start(profile.MemProfile, profile.MemProfileRate(1), profile.ProfilePath(".")).Stop()
} else if ProfileClock {
defer profile.Start(profile.ClockProfile, profile.ProfilePath(".")).Stop()
}
// Darkness needs something, if nothing given, then show help.
if len(os.Args) < 2 {
ichika.HelpCommandFunc()
return
}
// Find the supplied command...
if commandFunc := ichika.GetDarknessFunc(os.Args[1]); commandFunc != nil {
commandFunc()
return
}
// or show a snarky error message
fmt.Println("command not found?")
fmt.Println("see help, you pathetic excuse of a man")
}