Module: check_mk
Branch: master
Commit: 603b5d0e845f4923170ed10b5a82617ca7ca3e39
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=603b5d0e845f49…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Dec 21 13:33:33 2010 +0100
gb: allow filtering
---
gb | 26 +++++++++++++++++++++++++-
1 files changed, 25 insertions(+), 1 deletions(-)
diff --git a/gb b/gb
index 559d48f..af7fb6b 100755
--- a/gb
+++ b/gb
@@ -143,9 +143,33 @@ def show_bug(bug):
def main_list(args):
bugs = g_bugs.values()
+ # arguments are tags from state, component and class. Multiple values
+ # in one class are orred. Multiple types are anded.
+ filters = {}
+ for a in args:
+ hit = False
+ for tp, values in [
+ ( "component", components ), ( "state", states ), (
"class", classes ), ]:
+ for v in values:
+ if v.startswith(a):
+ entries = filters.get(tp, [])
+ entries.append(v)
+ filters[tp] = entries
+ hit = True
+ break
+ if hit:
+ break
+ if not hit:
+ bail_out("No such component, state or class: %s" % a)
+
# sort
for bug in bugs:
- if len(args) == 0 or bug["state"].startswith(args[0]):
+ skip = False
+ for tp, entries in filters.items():
+ if bug[tp] not in entries:
+ skip = True
+ break
+ if not skip:
list_bug(bug)