From 063c3ce425c76cc938b21de99a6e24086fc4b20a Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Fri, 20 Jun 2008 17:18:13 +0200 Subject: [PATCH] Move --size-unit and --count-unit from adu.ggo to select.ggo. --- adu.ggo | 31 +------------------------------ select.c | 42 +++++++++++++++++++++--------------------- select.ggo | 28 ++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 51 deletions(-) diff --git a/adu.ggo b/adu.ggo index 4be9373..55e5c5a 100644 --- a/adu.ggo +++ b/adu.ggo @@ -88,7 +88,7 @@ details=" " groupoption "interactive" I -#~~~~~~~~~~~~~~~~~~~~~ +#~~~~~~~~~~~~~~~~~~~~~~~~~~ "activate interactive mode" group="mode" details=" @@ -160,35 +160,6 @@ details=" Try --select-options \"-h\" " -option "size-unit" - -#~~~~~~~~~~~~~~~~~~~ -"select output format for sizes" -enum typestr="format" -values="h","b","k","m","g","t" -default="h" -optional -dependon="select" -details=" - Print sizes in the given unit: human-readable, bytes, - kilobytes (2^10), megabytes (2^20), gigabytes (2^30), terabytes - (2^40). The default is \"h\", i.e. human-readable. -" - -option "count-unit" - -#~~~~~~~~~~~~~~~~~~~~ -"select output format for counted values" -enum typestr="format" -values="h","n","k","m","g","t" -default="h" -optional -dependon="select" -details=" - Print the number of files/directories in the given unit: - human-readable, number, number/10^3, number/10^6, number/10^12, - number/10^15. The default is to print numbers in human-readable - format. -" - option "print-base-dir" - #~~~~~~~~~~~~~~~~~~~~~~~~ "whether to include the base-dir in the output" diff --git a/select.c b/select.c index ef63cf3..e095073 100644 --- a/select.c +++ b/select.c @@ -184,8 +184,8 @@ static int user_stats_loop_function(struct osl_row *row, void *data) goto err; files = *(uint64_t *)obj.data; if (usi->count && (usi->flags & USF_PRINT_FILES)) { - format_count_value(conf.count_unit_arg, files, - conf.count_unit_arg == count_unit_arg_h, + format_count_value(select_conf.count_unit_arg, files, + select_conf.count_unit_arg == count_unit_arg_h, formated_value); printf("\t%s%s", formated_value, (usi->flags & (USF_PRINT_BYTES | USF_PRINT_DIRNAME))? @@ -202,8 +202,8 @@ static int user_stats_loop_function(struct osl_row *row, void *data) goto err; bytes = *(uint64_t *)obj.data; if (usi->count && (usi->flags & USF_PRINT_BYTES)) { - format_size_value(conf.size_unit_arg, bytes, - conf.size_unit_arg == size_unit_arg_h, + format_size_value(select_conf.size_unit_arg, bytes, + select_conf.size_unit_arg == size_unit_arg_h, formated_value); printf("%s%s%s", (usi->flags & USF_PRINT_FILES)? "" : "\t", @@ -258,8 +258,8 @@ static int global_stats_loop_function(struct osl_row *row, void *data) goto err; files = *(uint64_t *)obj.data; if (gsi->count && (gsi->flags & GSF_PRINT_FILES)) { - format_count_value(conf.count_unit_arg, files, - conf.count_unit_arg == count_unit_arg_h, + format_count_value(select_conf.count_unit_arg, files, + select_conf.count_unit_arg == count_unit_arg_h, formated_value); printf("\t%s%s", formated_value, (gsi->flags & (GSF_PRINT_BYTES | GSF_PRINT_DIRNAME))? @@ -275,8 +275,8 @@ static int global_stats_loop_function(struct osl_row *row, void *data) goto err; bytes = *(uint64_t *)obj.data; if (gsi->count && (gsi->flags & GSF_PRINT_BYTES)) { - format_size_value(conf.size_unit_arg, bytes, - conf.size_unit_arg == size_unit_arg_h, + format_size_value(select_conf.size_unit_arg, bytes, + select_conf.size_unit_arg == size_unit_arg_h, formated_value); printf("%s%s%s", (gsi->flags & GSF_PRINT_FILES)? "" : "\t", @@ -341,9 +341,9 @@ static void print_global_summary(void) if (conf.no_global_summary_given) return; - ud = format_count_value(conf.count_unit_arg, num_dirs, 0, d); - uf = format_count_value(conf.count_unit_arg, num_files, 0, f); - us = format_size_value(conf.size_unit_arg, num_bytes, 0, s); + ud = format_count_value(select_conf.count_unit_arg, num_dirs, 0, d); + uf = format_count_value(select_conf.count_unit_arg, num_files, 0, f); + us = format_size_value(select_conf.size_unit_arg, num_bytes, 0, s); if (!conf.no_headers_given) printf("Global summary " @@ -361,14 +361,14 @@ static int print_user_summary_line(struct user_info *ui, __a_unused void *data) formated_file_count[FORMATED_VALUE_SIZE], formated_bytes[FORMATED_VALUE_SIZE ]; - format_count_value(conf.count_unit_arg, ui->dirs, - conf.count_unit_arg == count_unit_arg_h, + format_count_value(select_conf.count_unit_arg, ui->dirs, + select_conf.count_unit_arg == count_unit_arg_h, formated_dir_count); - format_count_value(conf.count_unit_arg, ui->files, - conf.count_unit_arg == count_unit_arg_h, + format_count_value(select_conf.count_unit_arg, ui->files, + select_conf.count_unit_arg == count_unit_arg_h, formated_file_count); - format_size_value(conf.size_unit_arg, ui->bytes, - conf.size_unit_arg == size_unit_arg_h, + format_size_value(select_conf.size_unit_arg, ui->bytes, + select_conf.size_unit_arg == size_unit_arg_h, formated_bytes); printf("\t%s\t%u\t%s\t%s\t%s\n", ui->pw_name? ui->pw_name : "?", @@ -607,12 +607,12 @@ int com_select(void) return ret; } - if (conf.count_unit_arg != count_unit_arg_h) - count_unit_buf[1] = count_unit_abbrevs[conf.count_unit_arg]; + if (select_conf.count_unit_arg != count_unit_arg_h) + count_unit_buf[1] = count_unit_abbrevs[select_conf.count_unit_arg]; else count_unit_buf[0] = '\0'; - if (conf.size_unit_arg != size_unit_arg_h) - size_unit_buf[1] = size_unit_abbrevs[conf.size_unit_arg]; + if (select_conf.size_unit_arg != size_unit_arg_h) + size_unit_buf[1] = size_unit_abbrevs[select_conf.size_unit_arg]; else size_unit_buf[0] = '\0'; diff --git a/select.ggo b/select.ggo index 33e75fe..a1de3a9 100644 --- a/select.ggo +++ b/select.ggo @@ -67,3 +67,31 @@ default="-" details=" If empty, or not given, use stdout. " + +option "size-unit" - +#~~~~~~~~~~~~~~~~~~~ +"select output format for sizes" +enum typestr="format" +values="h","b","k","m","g","t" +default="h" +optional +details=" + Print sizes in the given unit: human-readable, bytes, + kilobytes (2^10), megabytes (2^20), gigabytes (2^30), terabytes + (2^40). The default is \"h\", i.e. human-readable. +" + +option "count-unit" - +#~~~~~~~~~~~~~~~~~~~~ +"select output format for counted values" +enum typestr="format" +values="h","n","k","m","g","t" +default="h" +optional +details=" + Print the number of files/directories in the given unit: + human-readable, number, number/10^3, number/10^6, number/10^12, + number/10^15. The default is to print numbers in human-readable + format. +" + -- 2.39.5