aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThorsten Töpper <atsutane@freethoughts.de>2025-08-07 23:33:31 +0200
committerThorsten Töpper <atsutane@freethoughts.de>2025-08-07 23:34:37 +0200
commit371468655c0adbedbe5148fddd2dacaae9eac6e0 (patch)
treedbb63532c8be17d10eef28be2866907db352d305 /src
parentafdf29bc31744905e535c04d7f4804652e64e045 (diff)
downloaddir_monitor-371468655c0adbedbe5148fddd2dacaae9eac6e0.tar.gz
dir_monitor-371468655c0adbedbe5148fddd2dacaae9eac6e0.tar.bz2
options/output: add --quiet to suppress error/warning messages
As the LOGERR macro is modified this option will also suppress debug messages in case the executable was built with -DDEBUGBUILD.
Diffstat (limited to 'src')
-rw-r--r--src/options.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/options.c b/src/options.c
index 235792d..6aa913b 100644
--- a/src/options.c
+++ b/src/options.c
@@ -23,6 +23,7 @@ struct option long_options[] = {
{ "long-timestamp", no_argument, 0, 0 },
{ "print-boxed", no_argument, 0, 0 },
{ "print-header", no_argument, 0, 0 },
+ { "quiet", no_argument, 0, 0 },
{ "resolve-symlinks", no_argument, 0, 0 },
{ "reverse-sort", no_argument, 0, 0 },
{ "show-hidden-entries", no_argument, 0, 0 },
@@ -35,6 +36,7 @@ bool option_sort_reverse_order = false;
enum esort_type option_sort_type = SORT_BY_SIZE;
bool option_print_boxed_table = false;
bool option_print_header = false;
+bool option_quiet = false;
bool option_resolve_symlinks = false;
bool option_show_hidden_entries = false;
bool option_timestamp_long = false;
@@ -65,6 +67,8 @@ void usage(char *executable) {
"Print a boxed table");
fprintf(stderr, " %-25s %2s %10s - %s\n", "--print-header", "-H", "",
"Print a header above the columns");
+ fprintf(stderr, " %-25s %2s %10s - %s\n", "--quiet", "-q", "",
+ "Don't print error messages or warnings");
fprintf(stderr, " %-25s %2s %10s - %s\n", "--resolve-symlinks", "", "",
"the destination (name) of a symlink is resolved");
fprintf(stderr, " %-25s %2s %10s - %s\n", "--reverse-sort", "", "",
@@ -136,6 +140,11 @@ void set_option(const char *option_name, char *option_argument) {
return;
}
+ if (strcmp("quiet", option_name) == 0) {
+ option_quiet = true;
+ return;
+ }
+
if (strcmp("show-hidden-entries", option_name) == 0) {
option_show_hidden_entries = true;
return;
@@ -199,7 +208,7 @@ int parse_arguments(int argc, char **argv) {
while(1) {
index = 0;
- c = getopt_long(argc, argv, "abHhtf:", long_options, &index);
+ c = getopt_long(argc, argv, "abf:Hhqt", long_options, &index);
if (c == -1) {
break;
@@ -224,6 +233,9 @@ int parse_arguments(int argc, char **argv) {
case 'H':
option_print_header = true;
break;
+ case 'q':
+ option_quiet = true;
+ break;
case 't':
option_timestamp_long = true;
break;