diff options
author | 2015-02-23 18:00:06 -0800 | |
---|---|---|
committer | 2015-02-23 18:00:06 -0800 | |
commit | d6e3c023da778305efe8180835c6debba78e5138 (patch) | |
tree | 0c74bbc7f94b91d39007aa05a9e600ca1a449497 | |
parent | Expose delete index. (diff) | |
download | backend-d6e3c023da778305efe8180835c6debba78e5138.tar.gz backend-d6e3c023da778305efe8180835c6debba78e5138.tar.bz2 backend-d6e3c023da778305efe8180835c6debba78e5138.zip |
Ability to turn off the progress bar.
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
-rwxr-xr-x | ag | 20 | ||||
-rw-r--r-- | lib/storage.rb | 6 |
2 files changed, 23 insertions, 3 deletions
@@ -25,6 +25,7 @@ $options.no_threading = false $options.debug = false $options.readonly = false $options.jobs = false +$options.progress = true op = OptionParser.new do |opts| opts.banner = "Usage: ag <<--index-full|--index-new|--delete-msg|--delete-index|--reindex|--info> <--list listname>> <[--file|--msgid|--hash] <maildir/file/hash/messageid>> [options]" @@ -104,6 +105,13 @@ op = OptionParser.new do |opts| opts.on('--jobs JOBS', 'Number of parallel jobs to run (defaults to 75% of core count)') do |jobs| $options.jobs = jobs.to_i end + + opts.on('--progress', 'Display the progress bar') do + $options.progress = true + end + opts.on('--no-progress', 'Do not display the progress bar') do + $options.progress = false + end end op.parse! @@ -130,7 +138,11 @@ def do_full messages = $maildir.list(:cur) - Parallel.each(messages, in_processes: Ag::Utils.proc_count, progress: "Importing #{$options.name}") do |maildir_message| + opts = { + :in_processes: Ag::Utils.proc_count, + } + opts[:progress] = "Importing #{$options.name}" if $options.progress + Parallel.each(messages, opts) do |maildir_message| mail = maildir_message.data begin @@ -147,7 +159,11 @@ end def do_incremental messages = $maildir.list(:cur) - Parallel.each(messages, in_processes: Ag::Utils.proc_count, progress: "Importing #{$options.name}") do |maildir_message| + opts = { + :in_processes: Ag::Utils.proc_count, + } + opts[:progress] = "Importing #{$options.name}" if $options.progress + Parallel.each(messages, opts) do |maildir_message| mail = maildir_message.data begin diff --git a/lib/storage.rb b/lib/storage.rb index 656a6bf..8ab2d4e 100644 --- a/lib/storage.rb +++ b/lib/storage.rb @@ -232,7 +232,11 @@ module Ag::Storage } ) - Parallel.each(result['hits']['hits'], in_processes: Ag::Utils.proc_count, progress: "Calculating Threading (Pass #{pass})") do |hit| + opts = { + :in_processes => Ag::Utils.proc_count, + } + opts[:progress] = "Calculating Threading (Pass #{pass})" if $options.progress + Parallel.each(result['hits']['hits'], opts) do |hit| msg = resolve_message_id(list, hit['_source']['raw_parent']) unless msg == nil |