diff options
Diffstat (limited to 'src/options.c')
| -rw-r--r-- | src/options.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/options.c b/src/options.c index 8a2216d..293ca3d 100644 --- a/src/options.c +++ b/src/options.c @@ -19,6 +19,7 @@ /* === GLOBAL VARIABLES === */ struct option long_options[] = { { "help", no_argument, 0, 0 }, + { "format-string", required_argument, 0, 0 }, { "long-timestamp", no_argument, 0, 0 }, { "reverse-sort", no_argument, 0, 0 }, { "show-hidden-entries", no_argument, 0, 0 }, @@ -31,6 +32,7 @@ bool option_sort_reverse_order = false; enum esort_type option_sort_type = SORT_BY_SIZE; bool option_show_hidden_entries = false; bool option_timestamp_long = false; +char *option_format_string = NULL; /* There are three fields regarding time, valid values 'a','c', 'm': * st_atime / st_atim.tv_sec - time of the last access @@ -49,6 +51,8 @@ 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", "", "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", "--reverse-sort", "", "", @@ -63,6 +67,14 @@ void usage(char *executable) { /* fputc_width_x('-', 72, stderr); */ 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 - name\n"); + fprintf(stderr, " s - size\n"); + fprintf(stderr, " t - time defined by --time-field (default: modification time)\n"); + fprintf(stderr, " A - access time\n"); + fprintf(stderr, " C - change time\n"); + fprintf(stderr, " M - modification time\n"); } @@ -102,6 +114,11 @@ void set_option(const char *option_name, char *option_argument) { exit(EXIT_FAILURE); } + if (strcmp("format-string", option_name) == 0) { + option_format_string = option_argument; + return; + } + if (strcmp("sort-by", option_name) == 0) { if (strncmp("name", option_argument, 4) == 0) { option_sort_type = SORT_BY_NAME; |
