Skip to content

Commit 3b26199

Browse files
committed
(wip)
1 parent ab970f3 commit 3b26199

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pkg/cmd/time-entry/util/defaults/defaults.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ type ScanParam struct {
2727
Filename string
2828
}
2929

30+
// WriteDefaults persists the default values to a file
3031
func WriteDefaults(dir, filename string, d DefaultTimeEntry) error {
3132
n := filepath.Join(dir, filename)
3233
f, err := os.OpenFile(n, os.O_CREATE|os.O_RDWR, os.ModePerm)
@@ -41,20 +42,26 @@ func WriteDefaults(dir, filename string, d DefaultTimeEntry) error {
4142
return yaml.NewEncoder(f).Encode(d)
4243
}
4344

45+
// ScanError wraps errors from scanning for the defaults file
4446
type ScanError struct {
4547
Err error
4648
}
4749

50+
// Error shows error message
4851
func (s *ScanError) Error() string {
4952
return s.Unwrap().Error()
5053
}
5154

55+
// Unwrap gives access to the error chain
5256
func (s *ScanError) Unwrap() error {
5357
return s.Err
5458
}
5559

60+
// DefaultsFileNotFoundErr is returned when the scan can't find any files
5661
var DefaultsFileNotFoundErr = errors.New("defaults file not found")
5762

63+
// ScanForDefaults scan the directory informed and its parents for the defaults
64+
// file
5865
func ScanForDefaults(p ScanParam) func() (DefaultTimeEntry, error) {
5966
return func() (DefaultTimeEntry, error) {
6067
if p.Filename == "" {

0 commit comments

Comments
 (0)