add the --group argument

This commit is contained in:
Johann Dreo 2014-09-23 09:18:14 +02:00
commit 49e8b76c2d
2 changed files with 64 additions and 21 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` [-w] PATTERN COMMAND(S)
`paternoster` [-w] [-e] PATTERN COMMAND(S)
## DESCRIPTION
@ -25,20 +25,48 @@ silently ignored. If you ask for fewer commands, the last one will be
duplicated across remaining groups.
## OPTIONS
* `-h`, `--help`:
Show a help message and exit
* `-w`, `--nowait`:
Don't wait for the end of the current command before calling the next one.
* `-e`, `--end`:
Run commands at the end of the input stream.
* `-g`, `--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.
For example, if you capture 3 groups, you must put 3 formating placeholders in CMD:
`paternoster --group "^(.*):(.*):(.*)$" "echo '>>> 1:%s 2:%s 3:%s <<<'"`
## EXAMPLES
* Make the speakers beep for every FIXME found in a source code:
`cat source.ext | paternoster "FIXME" "beep"
`cat paternoster.py | paternoster "FIXME" "beep"
* Play a sound for each error or warning on a compiler output (you must have the
corresponding wav files somewhere in you path):
`make 2>&1 | paternoster ".*(error|warning): .*$" "play %s.wav"`
corresponding sound files in you path):
`make 2>&1 | paternoster ".*(error|warning): .*$" "ogg123 %s.ogg"`
* Say out loud the error in a compiler output:
`make 2>&1 | paternoster ".*(error: .*)$" "espeak --punct=';{}()' '%s'"`
* Play a series of sounds corresponding to the sequence of errors and warning
at the end of a compilation:
`make 2>&1 | paternoster --end ".*(error|warning): .*" "ogg123 %.ogg"`
* Notify the desktop every time a user logs in:
`tail -n 2 -f /var/log/auth.log | paternoster ".*session opened for user ([^\s]+)\s*" "notify-send '%s login'"`
* Notify the desktop every time a user logs in or out:
`tail -n 2 -f /var/log/auth.log | paternoster --group ".*session (opened|closed) for user ([^\s]+)\s*" "notify-send '%s %s'"`
## CREDITS
* Error sound by tcpp, licensed under CC-BY: http://www.freesound.org/people/tcpp/sounds/151309/
*