aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemsen2013-03-27 21:48:02 +0100
committerGravatar Tom Willemsen2013-03-27 21:48:02 +0100
commit86d790815080f1588041546e2b8515fc884e2973 (patch)
treef5aa05cfb356a2ecd7780d9427908f3713cdba08
parent703f8f7782a748648c4293a8b0b98f9a93ceb50f (diff)
downloadclark-86d790815080f1588041546e2b8515fc884e2973.tar.gz
clark-86d790815080f1588041546e2b8515fc884e2973.zip
Make simple commands check stderr
Don't assume all operations will complete successfully, check the error output to see if something happened.
-rw-r--r--js/clark.js43
1 files changed, 36 insertions, 7 deletions
diff --git a/js/clark.js b/js/clark.js
index 70cbc53..b1ea691 100644
--- a/js/clark.js
+++ b/js/clark.js
@@ -58,7 +58,7 @@ function clark_add_url(I, url, title)
+ tags.split(',').map(function (str)
{ return str.trim(); }).join("' '")
+ "'";
- yield shell_command(command);
+ yield clark_shell_command(command);
}
function clark_add(I) {
@@ -186,8 +186,12 @@ function clark_edit(I) {
if (description != "")
command += "--description '" + description + "' ";
- var result = yield shell_command(command);
- I.window.minibuffer.message("CLark done");
+ var result = yield clark_shell_command(command);
+
+ if (result)
+ I.window.minibuffer.message("CLark done");
+ else
+ I.window.minibuffer.message("Error during CLark operation.");
}
}
interactive("clark-edit", "Edit information for the current URL.",
@@ -228,8 +232,12 @@ function clark_remove(I) {
let url_string =
load_spec_uri_string(load_spec(I.buffer.top_frame));
let command = clark_program + ' remove "' + url_string + '"';
- let result = yield shell_command(command);
- I.window.minibuffer.message("CLark done");
+ let result = yield clark_shell_command(command);
+
+ if (result)
+ I.window.minibuffer.message("CLark done");
+ else
+ I.window.minibuffer.message("Error during CLark operation.");
}
interactive("clark-remove", "Remove the bookmark of the current URL"
+ " from the database.", clark_remove);
@@ -246,12 +254,33 @@ function clark_set_tags(I) {
+ tags.split(',').map(
function (str) { return "'" + str.trim() + "'"; }
).join(" ");
- let result = yield shell_command(command);
- I.window.minibuffer.message("CLark done");
+ let result = yield clark_shell_command(command);
+
+ if (result)
+ I.window.minibuffer.message("CLark done");
+ else
+ I.window.minibuffer.message("Error during CLark operation.");
}
interactive("clark-set-tags", "Replace the tags for the bookmark of"
+ " the current URL.", clark_set_tags);
+function clark_shell_command(command)
+{
+ let data = "", error = "";
+ yield shell_command(
+ command,
+ $fds = [{ output: async_binary_string_writer("") },
+ { input: async_binary_reader(
+ function (s) data += s || ""
+ )},
+ { input: async_binary_reader(
+ function (s) error += s || ""
+ )}]
+ );
+
+ yield co_return(error == "");
+}
+
define_keymap("clark_keymap");
define_key(clark_keymap, "?", "clark-exists-p");