Skip to content

Commit 04fb62b

Browse files
authored
Merge pull request #6 from koki-develop/feature/beep
2 parents 2a3606f + b262245 commit 04fb62b

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ Download the binary from the [releases page](https://github.com/koki-develop/she
3939
```sh
4040
$ sheep [time]
4141
# e.g.
42-
$ sheep 5
42+
$ sheep 5 # 5 seconds
43+
$ sheep 1h30m20s # 1 hour, 30 minutes, 20 seconds
4344
```
4445

4546
## LICENSE

cmd/root.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package cmd
22

33
import (
4-
"errors"
54
"fmt"
65
"os"
76
"runtime/debug"
@@ -14,10 +13,8 @@ import (
1413

1514
var (
1615
version string
17-
)
1816

19-
var (
20-
ErrInvalidDuration = errors.New("invalid duration")
17+
flagBeep bool
2118
)
2219

2320
var rootCmd = &cobra.Command{
@@ -38,7 +35,7 @@ var rootCmd = &cobra.Command{
3835
} else {
3936
duration, err = time.ParseDuration(args[0])
4037
if err != nil {
41-
return ErrInvalidDuration
38+
return err
4239
}
4340
}
4441

@@ -49,6 +46,9 @@ var rootCmd = &cobra.Command{
4946
if _, err := p.Run(); err != nil {
5047
return err
5148
}
49+
if flagBeep {
50+
fmt.Fprint(os.Stderr, "\a")
51+
}
5252
if m.Aborted() {
5353
os.Exit(130)
5454
}
@@ -72,4 +72,5 @@ func init() {
7272
}
7373
rootCmd.Version = version
7474

75+
rootCmd.Flags().BoolVarP(&flagBeep, "beep", "b", false, "beep when the sheep wakes up")
7576
}

0 commit comments

Comments
 (0)