From 97dfd4023230d2351e2850a05f30a6ea3cda7273 Mon Sep 17 00:00:00 2001 From: Joe Date: Mon, 12 Feb 2024 20:20:20 +0100 Subject: tmp --- src/c_utils.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/c_utils.go') diff --git a/src/c_utils.go b/src/c_utils.go index 3b94cc1..cfcba8e 100644 --- a/src/c_utils.go +++ b/src/c_utils.go @@ -52,6 +52,7 @@ package main import ( + "bytes" "errors" "fmt" "os" @@ -169,3 +170,33 @@ func c_decrypt_str(str string) (string, error) { out, err := cmd.Output() return string(out), err } + +func c_get_secret_gpg_keyring(ui *HardUI) []string { + var keys []string + var out bytes.Buffer + cmd_fmt := []string{ + `gpg`, + `--list-secret-keys`, + `|`, + `grep`, + `-A`, + `2`, + `'^sec'`, + `|`, + `sed`, + `'{/^sec/d;/--/d;s/^uid.*] //;}'`, + } + + ui.s.Fini() + cmd := exec.Command(cmd_fmt[0], cmd_fmt[1:]...) + cmd.Stdout = &out + if err := cmd.Run(); err != nil { + c_die("failed to list gpg secret keys", err) + c_error_mode("failed to list gpg secret keys", err, ui) + return nil + } + fmt.Printf("%s\n", out.String()) + os.Exit(0) + // keys[0] = string(cmd) + return keys +} -- cgit v1.2.3