Skip to content

Commit 22b5e01

Browse files
committed
Minor polishing
1 parent 93d0e51 commit 22b5e01

3 files changed

Lines changed: 54 additions & 44 deletions

File tree

pkg/config/default.go

Lines changed: 8 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,46 +6,14 @@
66

77
package config
88

9+
import (
10+
_ "embed"
11+
)
12+
13+
//go:embed default.yml
14+
var defaultYml string
15+
916
// Default returns the default configuration
1017
func Default() string {
11-
return `# Gaze configuration(priority: default < ~/.gaze.yml < ~/.config/gaze/gaze.yml < -f option)
12-
commands:
13-
- ext: .go
14-
cmd: go run "{{file}}"
15-
- ext: .py
16-
cmd: python "{{file}}"
17-
- ext: .rb
18-
cmd: ruby "{{file}}"
19-
- ext: .js
20-
cmd: node "{{file}}"
21-
- ext: .d
22-
cmd: dmd -run "{{file}}"
23-
- ext: .groovy
24-
cmd: groovy "{{file}}"
25-
- ext: .php
26-
cmd: php "{{file}}"
27-
- ext: .java
28-
cmd: java "{{file}}"
29-
- ext: .kts
30-
cmd: kotlinc -script "{{file}}"
31-
- ext: .rs
32-
cmd: |
33-
rustc "{{file}}" -o"{{base0}}.out"
34-
./"{{base0}}.out"
35-
- ext: .cpp
36-
cmd: |
37-
gcc "{{file}}" -o"{{base0}}.out"
38-
./"{{base0}}.out"
39-
- ext: .ts
40-
cmd: |
41-
tsc "{{file}}" --out "{{base0}}.out"
42-
node ./"{{base0}}.out"
43-
- ext: .zig
44-
cmd: zig run "{{file}}"
45-
- re: ^Dockerfile$
46-
cmd: docker build -f "{{file}}" .
47-
48-
log:
49-
start: "[{{command}}]{{step}}"
50-
end: "({{elapsed_ms}}ms)"`
18+
return defaultYml
5119
}

pkg/config/default.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Gaze configuration(priority: default < ~/.gaze.yml < ~/.config/gaze/gaze.yml < -f option)
2+
commands:
3+
- ext: .go
4+
cmd: go run "{{file}}"
5+
- ext: .py
6+
cmd: python "{{file}}"
7+
- ext: .rb
8+
cmd: ruby "{{file}}"
9+
- ext: .js
10+
cmd: node "{{file}}"
11+
- ext: .d
12+
cmd: dmd -run "{{file}}"
13+
- ext: .groovy
14+
cmd: groovy "{{file}}"
15+
- ext: .php
16+
cmd: php "{{file}}"
17+
- ext: .java
18+
cmd: java "{{file}}"
19+
- ext: .kts
20+
cmd: kotlinc -script "{{file}}"
21+
- ext: .rs
22+
cmd: |
23+
rustc "{{file}}" -o"{{base0}}.out"
24+
./"{{base0}}.out"
25+
- ext: .cpp
26+
cmd: |
27+
gcc "{{file}}" -o"{{base0}}.out"
28+
./"{{base0}}.out"
29+
- ext: .ts
30+
cmd: |
31+
tsc "{{file}}" --out "{{base0}}.out"
32+
node ./"{{base0}}.out"
33+
- ext: .zig
34+
cmd: zig run "{{file}}"
35+
- re: ^Dockerfile$
36+
cmd: docker build -f "{{file}}" .
37+
38+
log:
39+
start: "[{{command}}]{{step}}"
40+
end: "({{elapsed_ms}}ms)"

pkg/gazer/proc.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,19 @@ func executeCommand(cmd *exec.Cmd) CmdResult {
8585
cmd.Stderr = os.Stderr
8686

8787
start := time.Now()
88-
cmd.Start()
88+
err := cmd.Start()
89+
if err != nil {
90+
return CmdResult{StartTime: start, EndTime: time.Now(), Err: err}
91+
}
8992

9093
if cmd.Process != nil {
9194
logger.Info("Pid: %d", cmd.Process.Pid)
9295
} else {
9396
logger.Info("Pid: ????")
9497
}
95-
err := cmd.Wait()
98+
err = cmd.Wait()
9699

97-
end := time.Now()
98-
return CmdResult{StartTime: start, EndTime: end, Err: err}
100+
return CmdResult{StartTime: start, EndTime: time.Now(), Err: err}
99101
}
100102

101103
func kill(cmd *exec.Cmd, reason string) bool {

0 commit comments

Comments
 (0)