Refactor message printing
[stgit] / stgit / commands / applied.py
index 8a2a232..0925de0 100644 (file)
@@ -31,7 +31,11 @@ List the patches from the series which were already pushed onto the
 stack.  They are listed in the order in which they were pushed, the
 last one being the current (topmost) patch."""
 
-options = []
+options = [make_option('-b', '--branch',
+                       help = 'use BRANCH instead of the default one'),
+           make_option('-c', '--count',
+                       help = 'print the number of applied patches',
+                       action = 'store_true')]
 
 
 def func(parser, options, args):
@@ -40,5 +44,10 @@ def func(parser, options, args):
     if len(args) != 0:
         parser.error('incorrect number of arguments')
 
-    for p in crt_series.get_applied():
-        print p
+    applied = crt_series.get_applied()
+
+    if options.count:
+        out.stdout(len(applied))
+    else:
+        for p in applied:
+            out.stdout(p)