diff options
author | Marius <mariausol@gmail.com> | 2013-03-21 15:00:17 +0200 |
---|---|---|
committer | Marius <mariausol@gmail.com> | 2013-03-21 15:00:17 +0200 |
commit | 6bb39561d4571fb85aac56a686b837a9f3c910cd (patch) | |
tree | 87f9b55ac771b742532fec258c637c0b15ec7dae /scripts/context/lua/mtx-grep.lua | |
parent | 41df6a896ad3ab1d8bb6286423e9540b2b34f576 (diff) | |
download | context-6bb39561d4571fb85aac56a686b837a9f3c910cd.tar.gz |
beta 2013.03.21 13:42
Diffstat (limited to 'scripts/context/lua/mtx-grep.lua')
-rw-r--r-- | scripts/context/lua/mtx-grep.lua | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/scripts/context/lua/mtx-grep.lua b/scripts/context/lua/mtx-grep.lua index 98a97279d..dbcce67f6 100644 --- a/scripts/context/lua/mtx-grep.lua +++ b/scripts/context/lua/mtx-grep.lua @@ -7,12 +7,27 @@ if not modules then modules = { } end modules ['mtx-babel'] = { } local helpinfo = [[ ---pattern search for pattern (optional) ---count count matches only ---nocomment skip lines that start with %% or # ---xml pattern is lpath expression - -patterns are lua patterns and need to be escaped accordingly +<?xml version="1.0"?> +<application> + <metadata> + <entry name="name">mtx-grep</entry> + <entry name="detail">Simple Grepper</entry> + <entry name="version">0.10</entry> + </metadata> + <flags> + <category name="basic"> + <subcategory> + <flag name="pattern"><short>search for pattern (optional)</short></flag> + <flag name="count"><short>count matches only</short></flag> + <flag name="nocomment"><short>skip lines that start with %% or #</short></flag> + <flag name="xml"><short>pattern is lpath expression</short></flag> + </subcategory> + </category> + </flags> + <comments> + <comment>patterns are lua patterns and need to be escaped accordingly</comment> + </comments> +</application> ]] local application = logs.application { @@ -144,7 +159,9 @@ end local pattern = environment.argument("pattern") local files = environment.files and #environment.files > 0 and environment.files -if pattern and files then +if environment.argument("exporthelp") then + application.export(environment.argument("exporthelp"),files[1]) +elseif pattern and files then scripts.grep.find(pattern, files) elseif files then scripts.grep.find(files[1], files, 2) |