aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemsen2013-03-27 21:48:02 +0100
committerGravatar Tom Willemsen2013-03-27 21:48:02 +0100
commitcf50ebad50ef1c8321f0dde23afd28a51489b3c7 (patch)
tree63ad041d4fba61c0ee7b26938dcfc2f8fa152b3b
parent3ec871d500e79789f546d0425b069076e3f0a750 (diff)
downloadclark-conkeror-cf50ebad50ef1c8321f0dde23afd28a51489b3c7.tar.gz
clark-conkeror-cf50ebad50ef1c8321f0dde23afd28a51489b3c7.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--clark.js43
1 files changed, 36 insertions, 7 deletions
diff --git a/clark.js b/clark.js
index 70cbc53..b1ea691 100644
--- a/clark.js
+++ b/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");