quickjs client: silent, output, slight refactors
This commit is contained in:
parent
efb3f49e2d
commit
02f5223c52
|
@ -13,12 +13,12 @@ function editnote()
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
os.exec(["cp", "data/note.md", "data/backup.md"]);
|
os.exec(["cp", "data/note.md", "data/backup.md"]);
|
||||||
|
|
||||||
os.exec(settings.editor.concat("data/note.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)
|
||||||
{
|
{
|
||||||
|
print("diff:");
|
||||||
os.exec(["diff", "--color", "data/backup.md", "data/note.md"]);
|
os.exec(["diff", "--color", "data/backup.md", "data/note.md"]);
|
||||||
currentnote.content = newcontent;
|
currentnote.content = newcontent;
|
||||||
|
|
||||||
|
@ -29,20 +29,18 @@ function editnote()
|
||||||
file.puts(JSON.stringify(notes));
|
file.puts(JSON.stringify(notes));
|
||||||
file.close();
|
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");
|
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);
|
var postdata = "action=push&password=" + settings.password + "&data=" + encodeURIComponent(newdata);
|
||||||
file = std.open("data/postdata", "w");
|
file = std.open("data/postdata", "w");
|
||||||
file.puts(postdata);
|
file.puts(postdata);
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
os.exec(["curl", "-X", "POST",
|
os.exec(["curl", "-s", "-X", "POST",
|
||||||
"-d", "@data/postdata",
|
"-d", "@data/postdata",
|
||||||
settings.url + "/handler.php"]);
|
settings.url]);
|
||||||
|
|
||||||
console.log("...done.");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -66,8 +64,8 @@ if (command == "help" || command == "-h" || command == "--help")
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
os.exec(["curl", "-X", "POST", "-F", "action=fetch", "-F", "password=" + settings.password, "-o", "data/data.acs", settings.url + "/handler.php"]);
|
os.exec(["curl", "-s", "-X", "POST", "-F", "action=fetch", "-F", "password=" + settings.password, "-o", "data/data.acs", settings.url]);
|
||||||
os.exec([settings.gpg, "--yes", "--output", "data/data.json", "--decrypt", "data/data.acs"]);
|
os.exec([settings.gpg, "-q", "--yes", "--output", "data/data.json", "--decrypt", "data/data.acs"]);
|
||||||
var notes = JSON.parse(std.loadFile("data/data.json"));
|
var notes = JSON.parse(std.loadFile("data/data.json"));
|
||||||
|
|
||||||
switch (command)
|
switch (command)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"password": "",
|
"password": "",
|
||||||
"url": "http://localhost:8000",
|
"url": "http://localhost:8000/handler.php",
|
||||||
"editor": ["vim"],
|
"editor": ["vim"],
|
||||||
"gpg": "gpg",
|
"gpg": "gpg",
|
||||||
"gpguser": ""
|
"gpguser": ""
|
||||||
|
|
Loading…
Reference in New Issue