aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorRaymaekers Luca <raymaekers.luca@gmail.com>2024-10-19 22:41:08 +0200
committerRaymaekers Luca <raymaekers.luca@gmail.com>2024-10-19 22:41:08 +0200
commitb3c154d89bd7b20df247b3c7e6c43dc10c12a4e9 (patch)
tree439efc222329ba12b733f98ae4ba7ea7d078a5db /main.go
parentdfbb24d9956272a69fc5063dbc1adc67c7573a5e (diff)
Add date to printing
Added date to printing to differentiate commands with the same output. - Removed 'wbr:' prefix string
Diffstat (limited to 'main.go')
-rw-r--r--main.go16
1 files changed, 10 insertions, 6 deletions
diff --git a/main.go b/main.go
index be9d57b..a783bef 100644
--- a/main.go
+++ b/main.go
@@ -13,6 +13,7 @@ import (
"fmt"
"os/exec"
"strings"
+ "time"
"github.com/fsnotify/fsnotify"
)
@@ -41,6 +42,8 @@ var (
RunCommand []string
// Command will only run on files that have the Ext extension
Ext string
+const (
+ DateLayout string = "15:04:05"
)
func CompileRun(fileName string) {
@@ -59,13 +62,13 @@ func CompileRun(fileName string) {
// run the build command
out, err := buildCmd.CombinedOutput()
+ date := time.Now().Format(DateLayout)
if len(BuildCommand) > 1 {
- fmt.Printf("[%s%s %s%s]\n", Cyan, BuildCommand[0], strings.Join(append(BuildCommand[1:], fileName), " "), Reset)
+ fmt.Printf("[%s %s%s %s%s]\n", date, Cyan, BuildCommand[0], strings.Join(append(BuildCommand[1:], fileName), " "), Reset)
} else {
- fmt.Printf("[%s%s %s %s%s]\n", Cyan, BuildCommand[0], BuildCommand, fileName, Reset)
+ fmt.Printf("[%s %s%s %s %s%s]\n", date, Cyan, BuildCommand[0], BuildCommand, fileName, Reset)
}
- fmt.Println(len(BuildCommand))
if len(out) > 0 {
fmt.Printf("%s", out)
}
@@ -88,11 +91,12 @@ func CompileRun(fileName string) {
runCmd = exec.Command(RunCommand[0])
}
+ date := time.Now().Format(DateLayout)
out, err := runCmd.CombinedOutput()
if len(RunCommand) > 1 {
- fmt.Printf("[%s%s %s%s]\n", Cyan, RunCommand[0], strings.Join(RunCommand[1:], " "), Reset)
+ fmt.Printf("[%s %s%s %s%s]\n", date, Cyan, RunCommand[0], strings.Join(RunCommand[1:], " "), Reset)
} else {
- fmt.Printf("[%s%s%s]\n", Cyan, RunCommand[0], Reset)
+ fmt.Printf("[%s %s%s%s]\n", date, Cyan, RunCommand[0], Reset)
}
if len(out) > 0 {
@@ -128,7 +132,7 @@ func main() {
Ext = *e
Path = *p
- fmt.Printf("[%swbr%s:%s watching '%s'%s]\n", BoldCyan, Reset, Cyan, Path, Reset)
+ fmt.Printf("[%s watching '%s'%s]\n", Cyan, Path, Reset)
go func() {
for {