Command improvements.

This commit is contained in:
Nuno Cruces 2022-03-26 00:41:07 +00:00
parent 924fa398f8
commit 2c6ebc3c19

View File

@ -191,9 +191,9 @@ func setupFlags() {
flag.StringVar(&title, "title", "", "Set the dialog `title`") flag.StringVar(&title, "title", "", "Set the dialog `title`")
flag.UintVar(&width, "width", 0, "Set the `width`") flag.UintVar(&width, "width", 0, "Set the `width`")
flag.UintVar(&height, "height", 0, "Set the `height`") flag.UintVar(&height, "height", 0, "Set the `height`")
flag.StringVar(&okLabel, "ok-label", "", "Set the label of the OK button") flag.StringVar(&okLabel, "ok-label", "", "Set the `label` of the OK button")
flag.StringVar(&cancelLabel, "cancel-label", "", "Set the label of the Cancel button") flag.StringVar(&cancelLabel, "cancel-label", "", "Set the `label` of the Cancel button")
flag.StringVar(&extraButton, "extra-button", "", "Add an extra button") flag.Func("extra-button", "Add an extra `button`", setExtraButton)
flag.StringVar(&text, "text", "", "Set the dialog `text`") flag.StringVar(&text, "text", "", "Set the dialog `text`")
flag.StringVar(&icon, "window-icon", "", "Set the window `icon` (error, info, question, warning)") flag.StringVar(&icon, "window-icon", "", "Set the window `icon` (error, info, question, warning)")
flag.BoolVar(&multiple, "multiple", false, "Allow multiple items to be selected") flag.BoolVar(&multiple, "multiple", false, "Allow multiple items to be selected")
@ -210,7 +210,7 @@ func setupFlags() {
flag.BoolVar(&hideText, "hide-text", false, "Hide the entry text") flag.BoolVar(&hideText, "hide-text", false, "Hide the entry text")
// List options // List options
flag.Func("column", "Set the column header", addColumn) flag.Func("column", "Set the column `header`", addColumn)
flag.Bool("hide-header", true, "Hide the column headers") flag.Bool("hide-header", true, "Hide the column headers")
flag.BoolVar(&allowEmpty, "allow-empty", true, "Allow empty selection (macOS only)") flag.BoolVar(&allowEmpty, "allow-empty", true, "Allow empty selection (macOS only)")
@ -221,7 +221,7 @@ func setupFlags() {
flag.BoolVar(&confirmCreate, "confirm-create", false, "Confirm file selection if filename does not yet exist (Windows only)") flag.BoolVar(&confirmCreate, "confirm-create", false, "Confirm file selection if filename does not yet exist (Windows only)")
flag.BoolVar(&showHidden, "show-hidden", false, "Show hidden files (Windows and macOS only)") flag.BoolVar(&showHidden, "show-hidden", false, "Show hidden files (Windows and macOS only)")
flag.StringVar(&filename, "filename", "", "Set the `filename`") flag.StringVar(&filename, "filename", "", "Set the `filename`")
flag.Func("file-filter", "Set a filename filter (NAME | PATTERN1 PATTERN2 ...)", addFileFilter) flag.Func("file-filter", "Set a filename `filter` (NAME | PATTERN1 PATTERN2 ...)", addFileFilter)
// Color selection options // Color selection options
flag.StringVar(&defaultColor, "color", "", "Set the `color`") flag.StringVar(&defaultColor, "color", "", "Set the `color`")
@ -551,13 +551,21 @@ func egestPaths(paths []string, err error) ([]string, error) {
return paths, err return paths, err
} }
func addColumn(s string) error { func setExtraButton(s string) error {
columns++ if extraButton != unspecified {
if columns <= 1 { return errors.New("multiple extra buttons not supported")
}
extraButton = s
return nil return nil
} }
func addColumn(s string) error {
columns++
if columns > 1 {
return errors.New("multiple columns not supported") return errors.New("multiple columns not supported")
} }
return nil
}
func addFileFilter(s string) error { func addFileFilter(s string) error {
var filter zenity.FileFilter var filter zenity.FileFilter