fix(cli): correct du usage format and replace -h with -H

This commit is contained in:
zeyad 2026-05-12 20:58:53 +00:00
parent a6118e8d21
commit e75952e510
2 changed files with 4 additions and 4 deletions

View file

@ -21,7 +21,7 @@ By default, `du` prints human-readable sizes for each file and directory it enco
| `-d, --max-depth=N` | Stop at depth N; show only entries at or above depth N. | | `-d, --max-depth=N` | Stop at depth N; show only entries at or above depth N. |
| `-c, --total` | Print a grand total after all arguments have been processed. | | `-c, --total` | Print a grand total after all arguments have been processed. |
| `-b, --bytes` | Print sizes in exact bytes instead of human-readable units. | | `-b, --bytes` | Print sizes in exact bytes instead of human-readable units. |
| `-h, --human-readable` | Accepted for compatibility; human-readable is the default. | | `-H, --human-readable` | Accepted for compatibility; human-readable is the default. |
| `--help` | Display usage information and exit. | | `--help` | Display usage information and exit. |
## Output Format ## Output Format

View file

@ -22,7 +22,7 @@ static int opt_bytes = 0;
static uint64_t grand_total = 0; static uint64_t grand_total = 0;
static void usage(void) { static void usage(void) {
printf("Usage: du [OPTIONS]... [FILE]...\n"); printf("Usage: du [options]..[file]\n");
printf("Summarize disk usage of the set of FILEs, recursively for directories.\n\n"); printf("Summarize disk usage of the set of FILEs, recursively for directories.\n\n");
printf("Options:\n"); printf("Options:\n");
printf(" -s, --summarize display only a total for each argument\n"); printf(" -s, --summarize display only a total for each argument\n");
@ -31,7 +31,7 @@ static void usage(void) {
printf(" fewer levels below the command line argument\n"); printf(" fewer levels below the command line argument\n");
printf(" -c, --total produce a grand total\n"); printf(" -c, --total produce a grand total\n");
printf(" -b, --bytes print sizes in bytes\n"); printf(" -b, --bytes print sizes in bytes\n");
printf(" -h, --human-readable print sizes in human readable format (default)\n"); printf(" -H, --human-readable print sizes in human readable format (default)\n");
printf(" --help display this help and exit\n"); printf(" --help display this help and exit\n");
} }
@ -161,7 +161,7 @@ int main(int argc, char **argv) {
opt_total = 1; opt_total = 1;
} else if (strcmp(argv[i], "-b") == 0 || strcmp(argv[i], "--bytes") == 0) { } else if (strcmp(argv[i], "-b") == 0 || strcmp(argv[i], "--bytes") == 0) {
opt_bytes = 1; opt_bytes = 1;
} else if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--human-readable") == 0) { } else if (strcmp(argv[i], "-H") == 0 || strcmp(argv[i], "--human-readable") == 0) {
// No-op: human-readable is the default // No-op: human-readable is the default
} else if (strcmp(argv[i], "-d") == 0) { } else if (strcmp(argv[i], "-d") == 0) {
if (i + 1 < argc) { if (i + 1 < argc) {