Skip to content

Commit

Permalink
Merge pull request 99designs#295 from q3aiml/zenity-prompt
Browse files Browse the repository at this point in the history
add zenity prompt driver
  • Loading branch information
mtibben authored Oct 5, 2018
2 parents 4cf0045 + 89c298e commit 0cd0697
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
4 changes: 1 addition & 3 deletions prompt/osascript.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// +build darwin

package prompt

import (
Expand All @@ -9,7 +7,7 @@ import (
)

func OSAScriptPrompt(prompt string) (string, error) {
cmd := exec.Command("/usr/bin/osascript", "-e", fmt.Sprintf(`
cmd := exec.Command("osascript", "-e", fmt.Sprintf(`
display dialog "%s" default answer "" buttons {"OK", "Cancel"} default button 1
text returned of the result
return result`,
Expand Down
22 changes: 22 additions & 0 deletions prompt/zenity.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package prompt

import (
"fmt"
"os/exec"
"strings"
)

func ZenityPrompt(prompt string) (string, error) {
cmd := exec.Command("zenity", "--entry", "--title=aws-vault", fmt.Sprintf(`--text=%s`, prompt))

out, err := cmd.Output()
if err != nil {
return "", err
}

return strings.TrimSpace(string(out)), nil
}

func init() {
Methods["zenity"] = ZenityPrompt
}

0 comments on commit 0cd0697

Please sign in to comment.