diff --git a/filepicker/main.go b/filepicker/main.go index 3473dd2..0e85ba4 100644 --- a/filepicker/main.go +++ b/filepicker/main.go @@ -2,19 +2,27 @@ package main import ( "fmt" + "os" "github.com/harry1453/go-common-file-dialog/cfd" "github.com/harry1453/go-common-file-dialog/cfdutil" ) func main() { + // Check for extension arg + if len(os.Args) != 2 { + fmt.Println("Usage: filepicker ") + os.Exit(1) + } + var ext = os.Args[1] result, err := cfdutil.ShowOpenFileDialog(cfd.DialogConfig{ - Title: "Open An Executable", // Title of the dialog window - Role: "AtlasFilePick", // used to differentiate between different file picker dialogs - FileFilters: []cfd.FileFilter{{DisplayName: "Executable Files (*.exe)", Pattern: "*.exe"}}, + Title: "Select a File", // Title of the dialog window + Role: "AtlasFilePick", // used to differentiate between different file picker dialogs + FileFilters: []cfd.FileFilter{{DisplayName: ext + " Files", Pattern: "*." + ext}}, }) if err != nil { fmt.Println(err) + os.Exit(1) } fmt.Println(result) }