Allow first positional argument to be the password selection.

master
Ezekiel Grave 2020-04-19 10:53:19 -07:00
parent dfca1f44c5
commit 2aae3e9091
1 changed files with 21 additions and 10 deletions

View File

@ -2,6 +2,8 @@ package main
import (
"bytes"
"flag"
//"fmt"
"io"
"log"
"os"
@ -49,22 +51,31 @@ func call(stack []*exec.Cmd, pipes []*io.PipeWriter) (err error) {
}
func main() {
var b1 bytes.Buffer
if err := Execute(&b1,
exec.Command("qubes-pass-client", "list", "-f"),
exec.Command("tail", "-n", "+2"),
exec.Command("zenity", "--list", "--title", "Select a Password", "--column", "Password"),
); err != nil {
log.Fatalln(err)
}
selection := b1.String()
var selection string
flag.Parse()
switch specified := flag.Arg(0); specified {
case "":
//fmt.Printf("Specified: %q\n", specified)
var b1 bytes.Buffer
if err := Execute(&b1,
exec.Command("qubes-pass-client", "list", "-f"),
exec.Command("tail", "-n", "+2"),
exec.Command("zenity", "--list", "--width=666", "--height=999", "--title", "Select a Password", "--column", "Password"),
); err != nil {
log.Fatalln(err)
}
selection = b1.String()
//io.Copy(os.Stdout, &b1)
default:
//fmt.Printf("Specified: %q\n", specified)
selection = specified
}
var b2 bytes.Buffer
if err := Execute(&b2,
exec.Command("qubes-pass-client", "show", selection),
exec.Command("sed", "2q;d"),
exec.Command("timeout", "--preserve-status", "9", "xclip", "-quiet", "-loops", "1"),
exec.Command("timeout", "--preserve-status", "12", "xclip", "-quiet", "-loops", "1"),
); err != nil {
log.Fatalln(err)
}