filewatcherd

FreeBSD daemon that watches files and runs commands when they change
git clone https://git.instinctive.eu/filewatcherd.git
Log | Files | Refs | README | LICENSE

commit e5ca82340ffa19d9ea1e74771999279734f716b6
parent 57179a18400bdf2b0af7ef18ba72339d00e94102
Author: Natasha Kerensikova <natacha@instinctive.eu>
Date:   Wed, 21 Aug 2013 20:19:10 +0200

Move usage help text to log.c

Diffstat:
Mfilewatcherd.c | 13++-----------
Mlog.c | 18++++++++++++++++++
Mlog.h | 4++++
3 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/filewatcherd.c b/filewatcherd.c @@ -121,17 +121,8 @@ main(int argc, char **argv) { /* Display help text and terminate */ if (argerr || help) { - fprintf(argerr ? stderr : stdout, - "Usage: %s [-dh] [-f delay_ms] watchtab\n\n" - "\t-d, --foreground\n" - "\t\tDon't fork to background and log to stderr\n" - "\t-h, --help\n" - "\t\tDisplay this help text\n" - "\t-w, --wait delay_ms\n" - "\t\tWait that number of milliseconds after watchtab\n" - "\t\tchanges before reloading it\n", - argv[0]); - return argerr ? EXIT_FAILURE : EXIT_SUCCESS; + print_usage(!help, argc, argv); + return help ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/log.c b/log.c @@ -283,3 +283,21 @@ void log_watchtab_read(void) { report(LOG_ERR, "Error while reading from watchtab"); } + + +/* print_usage - output usage text upon request or after argument error */ +void +print_usage(int after_error, int argc, char **argv) { + (void)argc; + + fprintf(after_error ? stderr : stdout, + "Usage: %s [-dh] [-f delay_ms] watchtab\n\n" + "\t-d, --foreground\n" + "\t\tDon't fork to background and log to stderr\n" + "\t-h, --help\n" + "\t\tDisplay this help text\n" + "\t-w, --wait delay_ms\n" + "\t\tWait that number of milliseconds after watchtab\n" + "\t\tchanges before reloading it\n", + argv[0]); +} diff --git a/log.h b/log.h @@ -165,4 +165,8 @@ log_watchtab_loaded(const char *path); void log_watchtab_read(void); +/* print_usage - output usage text upon request or after argument error */ +void +print_usage(int after_error, int argc, char **argv); + #endif /* ndef FILEWATCHER_LOG_H */