X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=dus.c;h=336f20137d0988f2584cfd418a3dc8dc614f9d11;hb=2106033257340732a6703f6405dc97a08311e6f7;hp=5f481d7535d4a3a667385c738e40a1c2f759242d;hpb=dff998515d9469572147d445213cad08f12e4cb6;p=dus.git diff --git a/dus.c b/dus.c index 5f481d7..336f201 100644 --- a/dus.c +++ b/dus.c @@ -371,6 +371,8 @@ void usage(FILE *out) { fprintf(out, "Lists files and directories according to their size. The sizes are computed by summing recursively exact file sizes through directories. If a given directory has its name appended with '/', it is not listed, but the elements it contains are. If no files or directories are provided as arguments, the current directory is used as default.\n"); fprintf(out, "\n"); /* 01234567890123456789012345678901234567890123456789012345678901234567890123456789*/ + fprintf(out, " -h, --help show this help.\n"); + fprintf(out, " -v, --version prints the version number and exit\n"); fprintf(out, " -d, --ignore-dots ignore files and directories starting with a '.'\n"); fprintf(out, " -f, --fancy display size with float values and K, M and G\n"); fprintf(out, " units.\n"); @@ -383,7 +385,6 @@ void usage(FILE *out) { fprintf(out, " if the stdout is not a tty.\n"); fprintf(out, " -l , --nb-lines \n"); fprintf(out, " same as -c for number of lines.\n"); - fprintf(out, " -h, --help show this help.\n"); fprintf(out, " -m , --size-min \n"); fprintf(out, " set the listed entries minimum size. The size\n"); fprintf(out, " can be specified using the G, M, K, and B units.\n"); @@ -394,6 +395,7 @@ void usage(FILE *out) { /**********************************************************************/ static struct option long_options[] = { + { "version", no_argument, 0, 'v' }, { "ignore-dots", no_argument, 0, 'd' }, { "reverse-order", no_argument, 0, 'r' }, { "show-top", no_argument, 0, 't' }, @@ -414,10 +416,15 @@ int main(int argc, char **argv) { setlocale (LC_ALL, ""); - while ((c = getopt_long(argc, argv, "dfrtl:c:m:hd", + while ((c = getopt_long(argc, argv, "vdfrtl:c:m:hd", long_options, NULL)) != -1) { switch (c) { + case 'v': + printf("dus version %s (%s)\n", VERSION_NUMBER, UNAME); + exit(EXIT_SUCCESS); + break; + case 'd': ignore_dotfiles = 1; break;