Skip to content

Commit 8f90f4b

Browse files
committed
added --version flag
1 parent 32d7567 commit 8f90f4b

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
1.2.0
2+
-----
3+
4+
* added --version flag
5+
16
1.1.0
27
-----
38

main.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,18 @@ func main() {
4343
emails: os.Getenv("MAILTO"),
4444
}
4545

46+
var versionf bool
4647
flag.DurationVar(&req.timeout, "t", 0, `Timeout for the command, like "-t 2h", "-t 2m", or "-t 30s". After the timeout, the command is killed, disabled by default`)
4748
flag.StringVar(&req.transport, "p", "auto", `Transport to use, like "-p auto", "-p mail", "-p sendmail"`)
4849
flag.BoolVar(&req.verbose, "v", false, "Enable sending emails even if command is successful")
50+
flag.BoolVar(&versionf, "version", false, "Output the version")
4951
flag.Parse()
5052

53+
if versionf {
54+
fmt.Println(version)
55+
os.Exit(0)
56+
}
57+
5158
req.command = flag.Args()
5259
if len(req.command) == 0 {
5360
fmt.Println("You must pass a command to execute")
@@ -164,6 +171,8 @@ func (r *result) sendEmail() {
164171
}
165172
cmd := exec.Command(transportPath, "-t")
166173
cmd.Stdin = strings.NewReader(message)
174+
cmd.Stdout = os.Stdout
175+
cmd.Stderr = os.Stderr
167176
cmd.Env = os.Environ()
168177
if err := cmd.Run(); err != nil {
169178
fmt.Printf("Could not send email to %s: %s\n", emails, err)

0 commit comments

Comments
 (0)