-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtodo
executable file
·39 lines (32 loc) · 949 Bytes
/
todo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#! /usr/bin/gforth
\ Counts number of "TODO" items in code and appends to CSVFILE
require path.fs
require todolib.fs
: is-help-flag? {: addr1 u1 -- f :}
addr1 u1 s" -h" str= ( f )
addr1 u1 s" --help" str= ( f f )
or ( f )
;
: print-usage ( -- )
s" Usage: todo [-h/--help] [directories ...]" type cr cr
#tab emit s" Walks the provided directories (default: .)," type cr
#tab emit s" counts the number of 'TODO's in each file" type cr
#tab emit s" and writes to " type CSVFILE type cr
;
: main ( -- )
\ Go through args, if help flag provided, print usage and exit
argc @ 1 u+do
i arg is-help-flag? ( f )
if print-usage unloop exit endif
loop
argc @ 1- 0= if \ No argument provided, run on current directory
s" ." ['] todos-to-csv ( addr1 u1 xt ) exec-on-fstree exit
endif
\ Iterate through given directories
begin
next-arg 2dup 0 0 d<> while
['] todos-to-csv ( addr1 u1 xt )
exec-on-fstree
repeat
2drop ;
main bye