Skip to content

Commit 4c9e577

Browse files
committed
fix(ui): satisfy lint on zenity dialog helpers
1 parent 7bdf719 commit 4c9e577

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

pkg/ui/dlgs.go

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ func dialogResult(err error) (bool, error) {
1414
return false, nil
1515
}
1616

17-
return err == nil, err
17+
if err != nil {
18+
return false, fmt.Errorf("zenity dialog: %w", err)
19+
}
20+
21+
return true, nil
1822
}
1923

2024
// Warning wraps a warning dialog.
@@ -27,21 +31,21 @@ func Warning(title, msg string) (bool, error) {
2731
}
2832

2933
// Error wraps an error dialog.
30-
func Error(title, msg string, v ...any) (bool, error) {
34+
func Error(title, msg string, args ...any) (bool, error) {
3135
if !HasGUI() {
3236
return true, nil
3337
}
3438

35-
return dialogResult(zenity.Error(fmt.Sprintf(msg, v...), zenity.Title(title)))
39+
return dialogResult(zenity.Error(fmt.Sprintf(msg, args...), zenity.Title(title)))
3640
}
3741

3842
// Info wraps an info dialog.
39-
func Info(title, msg string, v ...any) (bool, error) {
43+
func Info(title, msg string, args ...any) (bool, error) {
4044
if !HasGUI() {
4145
return true, nil
4246
}
4347

44-
return dialogResult(zenity.Info(fmt.Sprintf(msg, v...), zenity.Title(title)))
48+
return dialogResult(zenity.Info(fmt.Sprintf(msg, args...), zenity.Title(title)))
4549
}
4650

4751
// Entry wraps a text-entry dialog.
@@ -54,12 +58,15 @@ func Entry(title, msg, val string) (string, bool, error) {
5458
if errors.Is(err, zenity.ErrCanceled) {
5559
return val, false, nil
5660
}
61+
if err != nil {
62+
return entry, false, fmt.Errorf("zenity entry: %w", err)
63+
}
5764

58-
return entry, err == nil, err
65+
return entry, true, nil
5966
}
6067

6168
// Question wraps a question dialog.
62-
func Question(title string, defaultCancel bool, text string, v ...any) (bool, error) {
69+
func Question(title string, defaultCancel bool, text string, args ...any) (bool, error) {
6370
if !HasGUI() {
6471
return true, nil
6572
}
@@ -69,5 +76,5 @@ func Question(title string, defaultCancel bool, text string, v ...any) (bool, er
6976
opts = append(opts, zenity.DefaultCancel())
7077
}
7178

72-
return dialogResult(zenity.Question(fmt.Sprintf(text, v...), opts...))
79+
return dialogResult(zenity.Question(fmt.Sprintf(text, args...), opts...))
7380
}

0 commit comments

Comments
 (0)