mirror of
https://github.com/rwinkhart/MUTN.git
synced 2026-09-05 16:47:20 -04:00
Write and append to config file using ini package
This commit is contained in:
+1
-1
@@ -72,7 +72,7 @@ func GenUpdate(targetLocation string, hideSecrets bool) {
|
|||||||
func editNote(baseNote []string) ([]string, bool) {
|
func editNote(baseNote []string) ([]string, bool) {
|
||||||
tempFile := backend.CreateTempFile()
|
tempFile := backend.CreateTempFile()
|
||||||
defer os.Remove(tempFile.Name())
|
defer os.Remove(tempFile.Name())
|
||||||
editor := backend.ReadConfig([]string{"textEditor"}, "")[0]
|
editor := backend.ParseConfig([]string{"textEditor"}, "")[0]
|
||||||
|
|
||||||
// write baseNote to tempFile (if it is not empty)
|
// write baseNote to tempFile (if it is not empty)
|
||||||
if len(baseNote) > 0 {
|
if len(baseNote) > 0 {
|
||||||
|
|||||||
+14
-9
@@ -8,7 +8,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TempInitCli initializes the MUTN environment based on user input
|
// TempInitCli initializes the MUTN environment based on user input (will be replaced with a TUI menu)
|
||||||
func TempInitCli() {
|
func TempInitCli() {
|
||||||
// gpgID
|
// gpgID
|
||||||
var gpgID string
|
var gpgID string
|
||||||
@@ -39,17 +39,22 @@ func TempInitCli() {
|
|||||||
sshKey := input("SSH private identity file path:") // TODO implement generator and selector
|
sshKey := input("SSH private identity file path:") // TODO implement generator and selector
|
||||||
sshKeyProtected := inputBinary("Is the identity file password-protected?")
|
sshKeyProtected := inputBinary("Is the identity file password-protected?")
|
||||||
|
|
||||||
// write config file
|
// initialize libmutton directories
|
||||||
backend.TempInit(map[string]string{"textEditor": textEditor, "gpgID": gpgID, "sshUser": sshUser, "sshIP": sshIP, "sshPort": sshPort, "sshKey": sshKey, "sshKeyProtected": strconv.FormatBool(sshKeyProtected), "sshEntryRoot": "null", "sshIsWindows": "null"}, false)
|
backend.DirInit(false)
|
||||||
|
|
||||||
// generate device ID
|
// write config file (temporarily assigns sshEntryRoot and sshIsWindows to null to pass initial device ID registration)
|
||||||
|
backend.WriteConfig(map[string]string{"textEditor": textEditor, "gpgID": gpgID, "sshUser": sshUser, "sshIP": sshIP, "sshPort": sshPort, "sshKey": sshKey, "sshKeyProtected": strconv.FormatBool(sshKeyProtected), "sshEntryRoot": "null", "sshIsWindows": "null"}, false)
|
||||||
|
|
||||||
|
// generate and register device ID
|
||||||
sshEntryRoot, sshIsWindows := sync.DeviceIDGen()
|
sshEntryRoot, sshIsWindows := sync.DeviceIDGen()
|
||||||
|
|
||||||
// update config file with sshEntryRoot and sshIsWindows TODO append to existing config file
|
// update config file with sshEntryRoot and sshIsWindows
|
||||||
backend.TempInit(map[string]string{"textEditor": textEditor, "gpgID": gpgID, "sshUser": sshUser, "sshIP": sshIP, "sshPort": sshPort, "sshKey": sshKey, "sshKeyProtected": strconv.FormatBool(sshKeyProtected), "sshEntryRoot": sshEntryRoot, "sshIsWindows": sshIsWindows}, true)
|
backend.WriteConfig(map[string]string{"sshEntryRoot": sshEntryRoot, "sshIsWindows": sshIsWindows}, true)
|
||||||
} else {
|
} else {
|
||||||
// write config file
|
// initialize libmutton directories
|
||||||
backend.TempInit(map[string]string{"textEditor": textEditor, "gpgID": gpgID}, false)
|
backend.DirInit(false)
|
||||||
}
|
|
||||||
|
|
||||||
|
// write config file
|
||||||
|
backend.WriteConfig(map[string]string{"textEditor": textEditor, "gpgID": gpgID}, false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user