Implement temporary "init" functionality

This commit is contained in:
2024-03-07 22:12:38 -05:00
parent 865490927b
commit 93a1a2209c
2 changed files with 21 additions and 5 deletions
+1 -5
View File
@@ -88,16 +88,12 @@ func EntryListGen() {
// check for errors encountered while walking directory
if err != nil {
// create EntryRoot if the error is the result of it not existing on the system
if os.IsNotExist(err) {
_ = os.Mkdir(offline.EntryRoot, 0700)
dirList = append(dirList, "")
fmt.Println(offline.AnsiError + "The entry directory does not exist - run \"mutn init\" to create it" + offline.AnsiReset)
} else {
// otherwise, print the source of the error
fmt.Println(offline.AnsiError + "An unexpected error occurred while generating the entry list: " + err.Error() + offline.AnsiReset)
}
// quit walking EntryRoot and return nil to allow the program to continue
return nil
}
// trim root path from each path before storing
+20
View File
@@ -0,0 +1,20 @@
package cli
import (
"github.com/rwinkhart/MUTN/src/offline"
"os"
"os/exec"
)
func TempInitCli() {
// gpgID
cmd := exec.Command("gpg", "-k")
cmd.Stdout = os.Stdout
cmd.Run()
gpgID := input("GPG key ID:")
// textEditor
textEditor := input("Text editor (leave blank for $EDITOR, falls back to \"vi\"):")
offline.TempInit(map[string]string{"textEditor": textEditor, "gpgID": gpgID})
}