@keywords a .
@prefix : <http://example.org/ns/plan3#> .
@prefix e: <grep#> .
@prefix i: <grep.n3#> .

<> doc "grep.n3 - Search Files for Pattern"; 
   usage ("grep.n3" opts "pattern" "filenames+" 
          ("-h" "--help" "Display a help message")
          ("-t" "--test" "Perform builtin code tests")); 
   dc:author [ foaf:homepage <http://inamidst.com/sbp/> ] .

e:grep def ((i:filenames i:pattern) 
   (doc "Grep through filenames for pattern")
   (example (e:grep ("tag:pluvo.org,2006:words") "ria")
            (prints "20. Thesmophoriazousae"))
   (for i:line (lines i:filenames)
      (if (search i:pattern i:line) do (out i:line))) .

e:args main 
   ((if (arg "--help") or (not args) do (help))
    (if (arg "--test") do (check e:grep) (quit))
    (e:grep args.filenames args.pattern)) .

# EOF

