about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2017-10-16 16:40:12 +0200
committerLeah Neukirchen <leah@vuxu.org>2017-10-16 16:40:12 +0200
commit250ed56bc4d54a0ed68bcf6ed1939e9c12f5df15 (patch)
treef3f56a652cb1787fb78a92448901d92c06cf79cc
parenta7a25be2e99cb6ba12461f77ed6c26ca5efd4098 (diff)
downloadnotyet-250ed56bc4d54a0ed68bcf6ed1939e9c12f5df15.tar.gz
notyet-250ed56bc4d54a0ed68bcf6ed1939e9c12f5df15.tar.xz
notyet-250ed56bc4d54a0ed68bcf6ed1939e9c12f5df15.zip
add -c flag to count only
-rwxr-xr-xnotyet9
1 files changed, 8 insertions, 1 deletions
diff --git a/notyet b/notyet
index 0bcaf6c..aacb9d6 100755
--- a/notyet
+++ b/notyet
@@ -1,5 +1,5 @@
 #!/usr/bin/env ruby
-# notyet [-a] [-e] [-f FILE] [FILTER] - a todo tracker
+# notyet [-a] [-c] [-e] [-f FILE] [FILTER] - a todo tracker
 #
 # notyet is in the public domain.
 # To the extent possible under law, Leah Neukirchen <leah@vuxu.org>
@@ -179,9 +179,11 @@ end
 files = []
 filter = []
 $show_all = $edit = false
+count_only = false
 ARGV.each_with_index { |arg, i|
   case arg
   when "-a"; $show_all = true
+  when "-c"; count_only = true
   when "-f"; files << ARGV.delete_at(i+1)
   when "-e"; $edit = true
   when /^-/; abort "Usage: notyet XXX"
@@ -209,6 +211,11 @@ t.propagate
 t.sort
 t.filter(filter)
 
+if count_only
+  puts "#{t.count("xX")}/#{t.count("-xX")}"
+  exit
+end
+
 if $edit && STDOUT.tty?
   rd, wr = IO.pipe
   $stdout = wr