public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Alex Legler" <a3li@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/ag:master commit in: /, lib/
Date: Mon, 23 Feb 2015 00:05:36 +0000 (UTC)	[thread overview]
Message-ID: <1424649905.3aeff5af03460eea82b31c493c6bfa635f80cf72.a3li@gentoo> (raw)

commit:     3aeff5af03460eea82b31c493c6bfa635f80cf72
Author:     Alex Legler <alex <AT> a3li <DOT> li>
AuthorDate: Mon Feb 23 00:05:05 2015 +0000
Commit:     Alex Legler <a3li <AT> gentoo <DOT> org>
CommitDate: Mon Feb 23 00:05:05 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/ag.git;a=commit;h=3aeff5af

Implement --info

---
 ag             | 23 ++++++++++++++++++++++-
 lib/storage.rb | 18 ++++++++++++++++++
 2 files changed, 40 insertions(+), 1 deletion(-)

diff --git a/ag b/ag
index be04609..29ee0f2 100755
--- a/ag
+++ b/ag
@@ -42,6 +42,12 @@ op = OptionParser.new do |opts|
     $options.action = :do_delete
   end
 
+  opts.on('--info', 'Display message details. Needs --file, --msgid, or --hash') do
+    abort 'Can only select one action' if $options.action != nil
+
+    $options.action = :do_info
+  end
+
   opts.on('--reindex', 'Reindex message. Needs --file') do
     abort 'Can only select one action' if $options.action != nil
 
@@ -144,7 +150,22 @@ def do_reindex
 end
 
 def do_info
-  abort 'Come back later.'
+  id = Ag::Utils.resolve_id
+
+  begin
+    message = Ag::Storage.get($options.name, id)
+
+    raise 'No such message' unless message
+
+    require 'pp'
+    str = "Message #{id}"
+    $stderr.puts str
+    $stderr.puts '-' * str.length
+
+    pp message['_source']
+  rescue => e
+    $stderr.puts "Cannot display message: #{e}"
+  end
 end
 
 ###############################################################################

diff --git a/lib/storage.rb b/lib/storage.rb
index 37083fa..b4a518e 100644
--- a/lib/storage.rb
+++ b/lib/storage.rb
@@ -220,4 +220,22 @@ module Ag::Storage
 
     result['hits']['total']
   end
+  def get(list, id)
+    result = $es.search(
+      index: 'ml-' + list,
+      size: 1,
+      body: {
+        query: {
+          filtered: {
+            filter: {
+              term: { _id: id }
+            }
+          }
+        }
+      }
+    )
+
+    return nil if result['hits']['total'] == 0
+    result['hits']['hits'].first
+  end
 end
\ No newline at end of file


             reply	other threads:[~2015-02-23  0:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-23  0:05 Alex Legler [this message]
  -- strict thread matches above, loose matches on Subject: below --
2015-02-24  2:17 [gentoo-commits] proj/ag:master commit in: /, lib/ Robin H. Johnson
2015-02-24  2:00 Robin H. Johnson
2015-02-23 22:44 Robin H. Johnson
2015-02-23 20:59 Alex Legler
2015-02-23  0:05 Alex Legler
2015-02-21 21:45 Robin H. Johnson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1424649905.3aeff5af03460eea82b31c493c6bfa635f80cf72.a3li@gentoo \
    --to=a3li@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox