mirror of
https://github.com/rwinkhart/MUTN.git
synced 2026-09-05 16:47:20 -04:00
Allow picking GPG key ID from a generated list
This commit is contained in:
+5
-6
@@ -2,16 +2,15 @@ package cli
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/rwinkhart/MUTN/src/offline"
|
"github.com/rwinkhart/MUTN/src/offline"
|
||||||
"os"
|
|
||||||
"os/exec"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TempInitCli() {
|
func TempInitCli() {
|
||||||
// gpgID
|
// gpgID
|
||||||
cmd := exec.Command("gpg", "-k")
|
//generateGPG := inputBinary("Auto-generate GPG key?")
|
||||||
cmd.Stdout = os.Stdout
|
|
||||||
cmd.Run()
|
uidSlice := offline.GpgUIDListGen()
|
||||||
gpgID := input("GPG key ID:")
|
gpgIDInt := inputMenuGen("Select GPG key:", uidSlice)
|
||||||
|
gpgID := uidSlice[gpgIDInt-1]
|
||||||
|
|
||||||
// textEditor
|
// textEditor
|
||||||
textEditor := input("Text editor (leave blank for $EDITOR, falls back to \"vi\"):")
|
textEditor := input("Text editor (leave blank for $EDITOR, falls back to \"vi\"):")
|
||||||
|
|||||||
@@ -34,14 +34,14 @@ func inputHidden(prompt string) string {
|
|||||||
return password
|
return password
|
||||||
}
|
}
|
||||||
|
|
||||||
// inputInt prompts the user for input and returns the input as an integer
|
// inputInt prompts the user for input and returns the input as an integer (0 is not a valid input)
|
||||||
func inputInt(prompt string) int {
|
func inputInt(prompt string) int {
|
||||||
// loop until a valid integer is entered
|
// loop until a valid integer is entered
|
||||||
for {
|
for {
|
||||||
fmt.Print("\n" + prompt + " ")
|
fmt.Print("\n" + prompt + " ")
|
||||||
var userInput int
|
var userInput int
|
||||||
_, err := fmt.Scanln(&userInput)
|
_, err := fmt.Scanln(&userInput)
|
||||||
if err == nil {
|
if err == nil && userInput > 0 {
|
||||||
return userInput
|
return userInput
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -58,6 +58,14 @@ func inputBinary(prompt string) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// inputMenu prompts the user with a menu and returns the user's choice as an integer
|
||||||
|
func inputMenuGen(prompt string, options []string) int {
|
||||||
|
for i, option := range options {
|
||||||
|
fmt.Printf("%d. %s\n", i+1, option)
|
||||||
|
}
|
||||||
|
return inputInt(prompt)
|
||||||
|
}
|
||||||
|
|
||||||
// writeEntryShortcut writes an entry to targetLocation (trimming trailing blank lines) and previews it, or errors if no data is supplied
|
// writeEntryShortcut writes an entry to targetLocation (trimming trailing blank lines) and previews it, or errors if no data is supplied
|
||||||
func writeEntryShortcut(targetLocation string, unencryptedEntry []string, hidePassword bool) {
|
func writeEntryShortcut(targetLocation string, unencryptedEntry []string, hidePassword bool) {
|
||||||
if offline.EntryIsNotEmpty(unencryptedEntry) {
|
if offline.EntryIsNotEmpty(unencryptedEntry) {
|
||||||
|
|||||||
Reference in New Issue
Block a user