Fix defaults (unix).

This commit is contained in:
Nuno Cruces 2021-03-04 12:35:27 +00:00
parent 7dc0e92528
commit abdae34d4e
4 changed files with 23 additions and 22 deletions

View File

@ -14,8 +14,8 @@ func selectColor(options []Option) (color.Color, error) {
args := []string{"--color-selection"}
if opts.title != "" {
args = append(args, "--title", opts.title)
if opts.title != nil {
args = append(args, "--title", *opts.title)
}
if opts.color != nil {
args = append(args, "--color", zenutil.UnparseColor(opts.color))

View File

@ -16,8 +16,8 @@ func selectFile(options []Option) (string, error) {
if opts.directory {
args = append(args, "--directory")
}
if opts.title != "" {
args = append(args, "--title", opts.title)
if opts.title != nil {
args = append(args, "--title", *opts.title)
}
if opts.filename != "" {
args = append(args, "--filename", opts.filename)
@ -44,8 +44,8 @@ func selectFileMutiple(options []Option) ([]string, error) {
if opts.directory {
args = append(args, "--directory")
}
if opts.title != "" {
args = append(args, "--title", opts.title)
if opts.title != nil {
args = append(args, "--title", *opts.title)
}
if opts.filename != "" {
args = append(args, "--filename", opts.filename)
@ -72,8 +72,8 @@ func selectFileSave(options []Option) (string, error) {
if opts.directory {
args = append(args, "--directory")
}
if opts.title != "" {
args = append(args, "--title", opts.title)
if opts.title != nil {
args = append(args, "--title", *opts.title)
}
if opts.filename != "" {
args = append(args, "--filename", opts.filename)

View File

@ -26,8 +26,8 @@ func message(kind messageKind, text string, options []Option) (bool, error) {
if text != "" {
args = append(args, "--text", text, "--no-markup")
}
if opts.title != "" {
args = append(args, "--title", opts.title)
if opts.title != nil {
args = append(args, "--title", *opts.title)
}
if opts.width > 0 {
args = append(args, "--width", strconv.FormatUint(uint64(opts.width), 10))
@ -35,14 +35,14 @@ func message(kind messageKind, text string, options []Option) (bool, error) {
if opts.height > 0 {
args = append(args, "--height", strconv.FormatUint(uint64(opts.height), 10))
}
if opts.okLabel != "" {
args = append(args, "--ok-label", opts.okLabel)
if opts.okLabel != nil {
args = append(args, "--ok-label", *opts.okLabel)
}
if opts.cancelLabel != "" {
args = append(args, "--cancel-label", opts.cancelLabel)
if opts.cancelLabel != nil {
args = append(args, "--cancel-label", *opts.cancelLabel)
}
if opts.extraButton != "" {
args = append(args, "--extra-button", opts.extraButton)
if opts.extraButton != nil {
args = append(args, "--extra-button", *opts.extraButton)
}
if opts.noWrap {
args = append(args, "--no-wrap")
@ -65,10 +65,11 @@ func message(kind messageKind, text string, options []Option) (bool, error) {
}
out, err := zenutil.Run(opts.ctx, args)
if err, ok := err.(*exec.ExitError); ok && err.ExitCode() != 255 {
if len(out) > 0 && string(out[:len(out)-1]) == opts.extraButton {
return false, ErrExtraButton
}
if len(out) > 0 && opts.extraButton != nil &&
string(out[:len(out)-1]) == *opts.extraButton {
return false, ErrExtraButton
}
if err, ok := err.(*exec.ExitError); ok && err.ExitCode() == 1 {
return false, nil
}
if err != nil {

View File

@ -14,8 +14,8 @@ func notify(text string, options []Option) error {
if text != "" {
args = append(args, "--text", text, "--no-markup")
}
if opts.title != "" {
args = append(args, "--title", opts.title)
if opts.title != nil {
args = append(args, "--title", *opts.title)
}
switch opts.icon {
case ErrorIcon: