diff options
| -rw-r--r-- | README.md | 8 | ||||
| -rw-r--r-- | man/dir_monitor.1.adoc | 10 | ||||
| -rw-r--r-- | src/options.c | 27 |
3 files changed, 24 insertions, 21 deletions
@@ -7,14 +7,14 @@ combination with watch it can be used for continous monitoring. OPTIONS ======= -Call: dir\_monitor OPTIONS path\_to\_open +Call: dir\_monitor [[OPTIONS]... path\_to\_open] | long | short | option | description | | ---- | ----- | ------ | ----------- | | `--help` | `-h` | | Show this message and exit | -| `--format-string` | `-f` | format | define columns to print, details below | +| `--format` | `-f` | format | define columns to print, details below | | `--long-timestamp` | `-t` | | Print timestamp in long form yyyymmdd HH:MM:SS ZONE | -| `--print-boxed` | | | Print visual additions around the table | +| `--print-boxed` | `-b` | | Print visual additions around the table | | `--print-header` | `-H` | | Print a header above the columns | | `--reverse-sort` | | | | Sort reversed | | `--show-hidden-entries` | `-a` | | Show hidden entries in the directory | @@ -25,7 +25,7 @@ Call: dir\_monitor OPTIONS path\_to\_open `--sort-by` variants: `name` | `size` | `time` -`--format-string` Aside from the characters in the table only space is +`--format` Aside from the characters in the table only space is accepted. Currently at max 80 bytes of the format string are processed. diff --git a/man/dir_monitor.1.adoc b/man/dir_monitor.1.adoc index 413d32c..e99924a 100644 --- a/man/dir_monitor.1.adoc +++ b/man/dir_monitor.1.adoc @@ -8,7 +8,7 @@ dir_monitor - present stat information of a path formatted and sorted == SYNOPSIS -**dir_monitor** [*OPTION*]... directory +**dir_monitor** [[*OPTION*]... directory] == DESCRIPTION @@ -19,7 +19,7 @@ It can be used for continuous monitoring of a path by wrappers like *watch*. == OPTIONS -**--format-string** 'format', **-f** 'format':: +**--format** 'format', **-f** 'format':: define columns to print, details below **--help**, **-h**:: @@ -28,7 +28,7 @@ define columns to print, details below **--long-timestamp**, **-t**:: Print timestamp in long form 'yyyymmdd HH:MM:SS ZONE' -**--print-boxed**:: +**--print-boxed**, **-b**:: Print output in form of a boxed table **--print-header**, **-H**:: @@ -47,7 +47,7 @@ Sort either by size or time Sort by (a)ccess, (c)hange or (m)odification time. Default: 'm' -=== format-string characters +=== format characters Other characters than the following are ignored. [cols=2] @@ -94,7 +94,7 @@ Other characters than the following are ignored. == EXAMPLES -dir_monitor --long-timestamp --print-header --format-string \'sAMn' --sort-by time --show-hidden /tmp +dir_monitor --long-timestamp --print-header --format \'sAMn' --sort-by time --show-hidden /tmp watch -d \'*dir_monitor -t -H /tmp/*' diff --git a/src/options.c b/src/options.c index d9fd6c0..b975794 100644 --- a/src/options.c +++ b/src/options.c @@ -19,7 +19,7 @@ /* === GLOBAL VARIABLES === */ struct option long_options[] = { { "help", no_argument, 0, 0 }, - { "format-string", required_argument, 0, 0 }, + { "format", required_argument, 0, 0 }, { "long-timestamp", no_argument, 0, 0 }, { "print-boxed", no_argument, 0, 0 }, { "print-header", no_argument, 0, 0 }, @@ -55,11 +55,11 @@ void usage(char *executable) { /* long name, short name, optional argument, explanation */ fprintf(stderr, " %-25s %2s %10s - %s\n", "--help", "-h", "", "Show this message and exit"); - fprintf(stderr, " %-25s %2s %10s - %s\n", "--format-string", "-f", "format", + fprintf(stderr, " %-25s %2s %10s - %s\n", "--format", "-f", "format", "define columns to print, details below"); fprintf(stderr, " %-25s %2s %10s - %s\n", "--long-timestamp", "-t", "", "Print timestamp in long form yyyymmdd HH:MM:SS ZONE"); - fprintf(stderr, " %-25s %2s %10s - %s\n", "--print-boxed", "", "", + fprintf(stderr, " %-25s %2s %10s - %s\n", "--print-boxed", "-b", "", "Print a boxed table"); fprintf(stderr, " %-25s %2s %10s - %s\n", "--print-header", "-H", "", "Print a header above the columns"); @@ -76,7 +76,7 @@ void usage(char *executable) { fprintf(stderr, "\n\n--sort-by variants: name | size | time\n"); - fprintf(stderr, "\n--format-string: Characters unlike the following are ignored\n"); + fprintf(stderr, "\n--format: Characters unlike the following are ignored\n"); fprintf(stderr, " A - access time\n"); fprintf(stderr, " C - change time\n"); fprintf(stderr, " G - group name\n"); @@ -138,7 +138,7 @@ void set_option(const char *option_name, char *option_argument) { exit(EXIT_FAILURE); } - if (strcmp("format-string", option_name) == 0) { + if (strcmp("format", option_name) == 0) { option_format_string = option_argument; return; } @@ -189,7 +189,7 @@ int parse_arguments(int argc, char **argv) { while(1) { index = 0; - c = getopt_long(argc, argv, "aHhtf:", long_options, &index); + c = getopt_long(argc, argv, "abHhtf:", long_options, &index); if (c == -1) { break; @@ -199,6 +199,15 @@ int parse_arguments(int argc, char **argv) { case 0: set_option(long_options[index].name, optarg); break; + case 'a': + option_show_hidden_entries = true; + break; + case 'b': + option_print_boxed_table = true; + break; + case 'f': + option_format_string = optarg; + break; case 'h': usage(exec_name); exit(EXIT_SUCCESS); @@ -208,12 +217,6 @@ int parse_arguments(int argc, char **argv) { case 't': option_timestamp_long = true; break; - case 'a': - option_show_hidden_entries = true; - break; - case 'f': - option_format_string = optarg; - break; case '?': break; default: |
