Skip to content

Commit

Permalink
Add ability to change file extension/filter
Browse files Browse the repository at this point in the history
  • Loading branch information
Zusier committed Nov 20, 2021
1 parent e91e7ff commit f3f8031
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions filepicker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 <ext>")
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)
}

0 comments on commit f3f8031

Please sign in to comment.