quickjs cli tool:

changed: allow command line params for editor
added: diff before push
changed: bypass confimation message for encryption
This commit is contained in:
quenousimporte 2023-09-11 09:54:33 +02:00
parent 73be3d91ee
commit f716fb83f1
2 changed files with 6 additions and 3 deletions

View File

@ -12,11 +12,14 @@ function editnote()
file.puts(currentnote.content); file.puts(currentnote.content);
file.close(); file.close();
os.exec([settings.editor, "data/note.md"]); os.exec(["cp", "data/note.md", "data/backup.md"]);
os.exec(settings.editor.concat("data/note.md"));
var newcontent = std.loadFile("data/note.md"); var newcontent = std.loadFile("data/note.md");
if (currentnote.content != newcontent) if (currentnote.content != newcontent)
{ {
os.exec(["diff", "--color", "data/backup.md", "data/note.md"]);
currentnote.content = newcontent; currentnote.content = newcontent;
notes.splice(notes.indexOf(currentnote), 1); notes.splice(notes.indexOf(currentnote), 1);
@ -26,7 +29,7 @@ function editnote()
file.puts(JSON.stringify(notes)); file.puts(JSON.stringify(notes));
file.close(); file.close();
os.exec([settings.gpg, "--encrypt", "--yes", "--output", "data/data2.acs", "--armor", "-r", settings.gpguser, "data/data2.json"]); os.exec([settings.gpg, "--encrypt", "--yes", "--trust-model", "always", "--output", "data/data2.acs", "--armor", "-r", settings.gpguser, "data/data2.json"]);
var newdata = std.loadFile("data/data2.acs"); var newdata = std.loadFile("data/data2.acs");
console.log("sending data file to server..."); console.log("sending data file to server...");

View File

@ -1,7 +1,7 @@
{ {
"password": "", "password": "",
"url": "http://localhost:8000", "url": "http://localhost:8000",
"editor": "vim", "editor": ["vim"],
"gpg": "gpg", "gpg": "gpg",
"gpguser": "" "gpguser": ""
} }