From 02f5223c52b22b4c1bcdb053339fe36c324cecb9 Mon Sep 17 00:00:00 2001 From: quenousimporte Date: Tue, 12 Sep 2023 09:06:58 +0200 Subject: [PATCH] quickjs client: silent, output, slight refactors --- cli/quick/app.js | 16 +++++++--------- cli/quick/settingssample.json | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/cli/quick/app.js b/cli/quick/app.js index 91342c3..b12d28b 100644 --- a/cli/quick/app.js +++ b/cli/quick/app.js @@ -13,12 +13,12 @@ function editnote() file.close(); os.exec(["cp", "data/note.md", "data/backup.md"]); - os.exec(settings.editor.concat("data/note.md")); var newcontent = std.loadFile("data/note.md"); if (currentnote.content != newcontent) { + print("diff:"); os.exec(["diff", "--color", "data/backup.md", "data/note.md"]); currentnote.content = newcontent; @@ -29,20 +29,18 @@ function editnote() file.puts(JSON.stringify(notes)); file.close(); - os.exec([settings.gpg, "--encrypt", "--yes", "--trust-model", "always", "--output", "data/data2.acs", "--armor", "-r", settings.gpguser, "data/data2.json"]); + os.exec([settings.gpg, "-q", "--encrypt", "--yes", "--trust-model", "always", "--output", "data/data2.acs", "--armor", "-r", settings.gpguser, "data/data2.json"]); var newdata = std.loadFile("data/data2.acs"); - console.log("sending data file to server..."); + console.log("sending data file to server."); var postdata = "action=push&password=" + settings.password + "&data=" + encodeURIComponent(newdata); file = std.open("data/postdata", "w"); file.puts(postdata); file.close(); - os.exec(["curl", "-X", "POST", + os.exec(["curl", "-s", "-X", "POST", "-d", "@data/postdata", - settings.url + "/handler.php"]); - - console.log("...done."); + settings.url]); } else { @@ -66,8 +64,8 @@ if (command == "help" || command == "-h" || command == "--help") } else { - os.exec(["curl", "-X", "POST", "-F", "action=fetch", "-F", "password=" + settings.password, "-o", "data/data.acs", settings.url + "/handler.php"]); - os.exec([settings.gpg, "--yes", "--output", "data/data.json", "--decrypt", "data/data.acs"]); + os.exec(["curl", "-s", "-X", "POST", "-F", "action=fetch", "-F", "password=" + settings.password, "-o", "data/data.acs", settings.url]); + os.exec([settings.gpg, "-q", "--yes", "--output", "data/data.json", "--decrypt", "data/data.acs"]); var notes = JSON.parse(std.loadFile("data/data.json")); switch (command) diff --git a/cli/quick/settingssample.json b/cli/quick/settingssample.json index 7ffece7..7ec5e09 100644 --- a/cli/quick/settingssample.json +++ b/cli/quick/settingssample.json @@ -1,6 +1,6 @@ { "password": "", - "url": "http://localhost:8000", + "url": "http://localhost:8000/handler.php", "editor": ["vim"], "gpg": "gpg", "gpguser": ""