Add timing stuff

master
kolaente 5 years ago
parent 80e9d69813
commit e52ee09990
Signed by: kolaente
GPG Key ID: F40E70337AB24C9B
  1. 10
      cmd/root.go

@ -4,6 +4,7 @@ import (
"bufio"
"fmt"
"os"
"time"
"github.com/spf13/cobra"
@ -22,10 +23,19 @@ var rootCommand = &cobra.Command{
Args: cobra.ExactArgs(1),
Use: "hal",
RunE: runRootCommand,
PreRun: func(cmd *cobra.Command, args []string) {
startTime = time.Now()
},
PostRun: func(cmd *cobra.Command, args []string) {
totalTime := time.Since(startTime)
fmt.Printf("Total execution time: %v", totalTime)
},
}
var debug bool
var startTime time.Time
func init() {
rootCommand.Flags().BoolVarP(&debug, "debug", "d", false, "Enable debug mode")
}

Loading…
Cancel
Save