better explanations

This commit is contained in:
Johann Dreo 2014-09-23 10:58:33 +02:00
commit 5f18ecf6fc
2 changed files with 7 additions and 7 deletions

View file

@ -8,7 +8,7 @@ A command line tool that call the given command for each input line matching the
`paternoster` [-h] `paternoster` [-h]
`paternoster` [-w] [-e] PATTERN COMMAND(S) `paternoster` [-w] [-e] [-g] PATTERN COMMAND(S)
## DESCRIPTION ## DESCRIPTION
@ -32,15 +32,21 @@ duplicated across remaining groups.
* `-w`, `--nowait`: * `-w`, `--nowait`:
Don't wait for the end of the current command before calling the next one. Don't wait for the end of the current command before calling the next one.
This will call commands as soon as they are met in the stream,
If the stream is read fast, commands will most probably be ran quasi-simultaneously.
* `-e`, `--end`: * `-e`, `--end`:
Run commands at the end of the input stream. Run commands at the end of the input stream.
Note that if the stream don't end (for example if you input from `tail -f`),
nothing will be done until an interruption.
* `-g`, `--group`: * `-g`, `--group`:
Capture groups as arguments for the CMD, instead of running CMD for each group. Capture groups as arguments for the CMD, instead of running CMD for each group.
CMD must have as many formating placeholder as captured groups. CMD must have as many formating placeholder as captured groups.
For example, if you capture 3 groups, you must put 3 formating placeholders in CMD: For example, if you capture 3 groups, you must put 3 formating placeholders in CMD:
`paternoster --group "^(.*):(.*):(.*)$" "echo '>>> 1:%s 2:%s 3:%s <<<'"` `paternoster --group "^(.*):(.*):(.*)$" "echo '>>> 1:%s 2:%s 3:%s <<<'"`
If placeholders count does not match the groups count, no substitution is made
and the placeholders are left as is.
## EXAMPLES ## EXAMPLES

View file

@ -93,11 +93,6 @@ def read_parse( stream_in, stream_out, pattern, cmd, nowait = False, at_end = Fa
Read the given file-like object as a non-blocking stream Read the given file-like object as a non-blocking stream
and call the function on each item (line), and call the function on each item (line),
with the given extra arguments. with the given extra arguments.
A call to "map_write(sys.stdin, function, *args)" will translate to the
non-blocking equivalent of:
for item in sys.stdin.readlines():
write( function( *args ) )
""" """
if at_end: if at_end:
@ -138,7 +133,6 @@ if __name__ == "__main__":
help="A regular expression") help="A regular expression")
parser.add_argument("commands", metavar="CMD", type=str, nargs="+", parser.add_argument("commands", metavar="CMD", type=str, nargs="+",
default="espeak %s",
help="The command to run if REGEX match. \ help="The command to run if REGEX match. \
If CMD contains a string formating placefolder (like \"%%s\"), \ If CMD contains a string formating placefolder (like \"%%s\"), \
it will be replaced by the matching text. \ it will be replaced by the matching text. \