21 lines
495 B
Go
21 lines
495 B
Go
package dialog
|
|
|
|
import (
|
|
"fmt"
|
|
"os/exec"
|
|
"strings"
|
|
)
|
|
|
|
func PickFolder() (string, error) {
|
|
cmd := exec.Command("osascript", "-e", `POSIX path of (choose folder with prompt "Select a folder")`)
|
|
out, err := cmd.CombinedOutput()
|
|
if err != nil {
|
|
return "", fmt.Errorf("folder selection failed: %s", strings.TrimSpace(string(out)))
|
|
}
|
|
path := strings.TrimSpace(string(out))
|
|
if path == "" {
|
|
return "", fmt.Errorf("folder selection canceled")
|
|
}
|
|
return strings.TrimSuffix(path, "/"), nil
|
|
}
|