summaryrefslogtreecommitdiff
path: root/cmd/dtail-tools/main.go
blob: 2b96a56bc5b29eaa3775a54be3686970774ce191 (plain)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package main

import (
	"fmt"
	"os"

	"github.com/mimecast/dtail/internal/tools/benchmark"
	"github.com/mimecast/dtail/internal/tools/pgo"
	"github.com/mimecast/dtail/internal/tools/profile"
)

func main() {
	if len(os.Args) < 2 {
		printUsage()
		os.Exit(1)
	}

	command := os.Args[1]
	
	// Remove command from args for subcommand parsing
	os.Args = append([]string{os.Args[0]}, os.Args[2:]...)

	switch command {
	case "profile":
		if err := profile.Run(); err != nil {
			fmt.Fprintf(os.Stderr, "Error: %v\n", err)
			os.Exit(1)
		}
	case "benchmark":
		if err := benchmark.Run(); err != nil {
			fmt.Fprintf(os.Stderr, "Error: %v\n", err)
			os.Exit(1)
		}
	case "pgo":
		if err := pgo.Run(); err != nil {
			fmt.Fprintf(os.Stderr, "Error: %v\n", err)
			os.Exit(1)
		}
	case "help", "-h", "--help":
		printUsage()
	default:
		fmt.Fprintf(os.Stderr, "Unknown command: %s\n", command)
		printUsage()
		os.Exit(1)
	}
}

func printUsage() {
	fmt.Println("dtail-tools - DTail performance analysis toolkit")
	fmt.Println()
	fmt.Println("Usage: dtail-tools <command> [options]")
	fmt.Println()
	fmt.Println("Commands:")
	fmt.Println("  profile    Run profiling on dtail commands")
	fmt.Println("  benchmark  Run benchmarks and manage baselines")
	fmt.Println("  pgo        Profile-Guided Optimization for dtail commands")
	fmt.Println("  help       Show this help message")
	fmt.Println()
	fmt.Println("Run 'dtail-tools <command> -h' for command-specific help")
}