Skip to content

Commit 35db030

Browse files
committed
command/search: add number-only option
Only display the numbers of the matched bugs and not the summary. Signed-off-by: Thomas Faivre <thomas.faivre@6wind.com>
1 parent 75acc03 commit 35db030

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

bzlib/command.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,13 @@ def with_field(cls):
9090
return cls
9191

9292

93+
def with_id_only(cls):
94+
cls.args = cls.args + [
95+
lambda x: x.add_argument('--number-only', action='store_true',
96+
help='Display bug number only.'),
97+
]
98+
return cls
99+
93100
def with_bugs(cls):
94101
cls.args = cls.args + [
95102
lambda x: x.add_argument('bugs', metavar='BUG', type=int, nargs='+',
@@ -838,6 +845,7 @@ def _make_set_arguments_group(cls, group):
838845
help=template.format('NOT ')),
839846

840847

848+
@with_id_only
841849
@with_group('search criteria', _make_set_arguments_group)
842850
class Search(BugzillaCommand):
843851
"""Search for bugs matching given criteria.
@@ -862,6 +870,10 @@ def __call__(self):
862870
bugs = list(bug_module.Bug.search(self.bz, **kwargs))
863871
lens = [len(str(b.bugno)) for b in bugs]
864872

873+
if self._args.number_only:
874+
print(' '.join(map(lambda x: str(x.bugno), bugs)))
875+
return
876+
865877
for bug in bugs:
866878
print('Bug {:{}} {}'.format(
867879
str(bug.bugno) + ':', max(lens) - min(lens) + 2,

0 commit comments

Comments
 (0)