aboutsummaryrefslogtreecommitdiff
path: root/ag
diff options
context:
space:
mode:
Diffstat (limited to 'ag')
-rwxr-xr-xag42
1 files changed, 40 insertions, 2 deletions
diff --git a/ag b/ag
index c220b9d..d54cabe 100755
--- a/ag
+++ b/ag
@@ -28,9 +28,11 @@ $options.jobs = false
$options.progress = true
$options.need_argument = true
$options.argmode = nil
+$options.comment = nil
op = OptionParser.new do |opts|
- opts.banner = "Usage: ag <<--index-full|--index-new|--delete-msg|--delete-index|--reindex|--rethread|--info> <--list listname>> <[--file|--msgid|--hash] <maildir/file/hash/messageid>> [options]"
+ actions = %w(hide-msg unhide-msg index-full index-new delete-msg delete-index reindex rethread info).map { |s| '--'+s }.join('|')
+ opts.banner = "Usage: ag <<#{actions}>> <--list listname>> <[--file|--msgid|--hash] <maildir/file/hash/messageid>> [options]"
opts.on('--index-full', 'Read the full past archive from Maildir/cur. Does --delete-index by default. Needs --list and a Maildir') do
abort 'Can only select one action' if $options.action != nil
@@ -52,13 +54,25 @@ op = OptionParser.new do |opts|
$options.action = :do_delete_msg
end
+ opts.on('--hide-msg', 'Hides a message. Needs --list and one of --file, --msgid, or --hash') do
+ abort 'Can only select one action' if $options.action != nil
+
+ $options.action = :do_hide_msg
+ end
+
+ opts.on('--unhide-msg', 'Unhides a message. Needs --list and one of --file, --msgid, or --hash') do
+ abort 'Can only select one action' if $options.action != nil
+
+ $options.action = :do_unhide_msg
+ end
+
opts.on('--create-index', 'Create index but do not populate. Needs --list') do
abort 'Can only select one action' if $options.action != nil
$options.action = :do_create_index
$options.need_argument = false
end
-
+
opts.on('--rethread', 'Rethread messages. Needs --list') do
abort 'Can only select one action' if $options.action != nil
@@ -131,6 +145,10 @@ op = OptionParser.new do |opts|
opts.on('--no-progress', 'Do not display the progress bar') do
$options.progress = false
end
+
+ opts.on('--comment COMMENT', 'Comment string as why the message is being hidden/unhidden.') do |comment|
+ $options.comment = comment
+ end
end
op.parse!
@@ -215,6 +233,26 @@ def do_delete_msg
end
end
+def do_hide_msg
+ id = Ag::Utils.resolve_id
+
+ begin
+ Ag::Storage.hide($options.name, id, $options.comment)
+ rescue => e
+ $stderr.puts "Cannot hide message: #{e}"
+ end
+end
+
+def do_unhide_msg
+ id = Ag::Utils.resolve_id
+
+ begin
+ Ag::Storage.unhide($options.name, id, $options.comment)
+ rescue => e
+ $stderr.puts "Cannot unhide message: #{e}"
+ end
+end
+
def do_delete_index(ignore_missing: false, _raise: false)
begin
Ag::Storage.delete_index($options.name)