diff --git a/c/cli/argparse.c b/c/cli/argparse.c index 5b95a951f..e67bada41 100644 --- a/c/cli/argparse.c +++ b/c/cli/argparse.c @@ -6,6 +6,7 @@ typedef enum _ap_flag_t { AP_INT_VALUE_FLAG, AP_INT_FLAG, + AP_LONG_LONG_FLAG, AP_DOUBLE_FLAG, AP_STRING_FLAG, AP_STRING_LIST_FLAG, @@ -86,6 +87,9 @@ void ap_define_int_value_flag(ap_state_t* pstate, char* flag_name, int intval, i void ap_define_int_flag(ap_state_t* pstate, char* flag_name, int* pintval) { sllv_append(pstate->pflag_defs, ap_flag_def_alloc(flag_name, AP_INT_FLAG, 0, pintval, 2)); } +void ap_define_long_long_flag(ap_state_t* pstate, char* flag_name, long long* pintval) { + sllv_append(pstate->pflag_defs, ap_flag_def_alloc(flag_name, AP_LONG_LONG_FLAG, 0, pintval, 2)); +} void ap_define_float_flag(ap_state_t* pstate, char* flag_name, double* pdoubleval) { sllv_append(pstate->pflag_defs, ap_flag_def_alloc(flag_name, AP_DOUBLE_FLAG, 0, pdoubleval, 2)); @@ -148,6 +152,13 @@ int ap_parse_aux(ap_state_t* pstate, char* verb, int* pargi, int argc, char** ar fprintf(stderr, "\n"); } + } else if (pdef->type == AP_LONG_LONG_FLAG) { + if (sscanf(argv[argi+1], "%lld", (long long *)pdef->pval) != 1) { + fprintf(stderr, "%s %s: couldn't parse \"%s\" after \"%s\" as integer.\n", + argv[0], verb, argv[argi+1], argv[argi]); + fprintf(stderr, "\n"); + } + } else if (pdef->type == AP_DOUBLE_FLAG) { if (!mlr_try_float_from_string(argv[argi+1], (double *)pdef->pval)) { fprintf(stderr, "%s %s: couldn't parse \"%s\" after \"%s\" as double.\n", diff --git a/c/cli/argparse.h b/c/cli/argparse.h index c15b78f60..be5148850 100644 --- a/c/cli/argparse.h +++ b/c/cli/argparse.h @@ -19,6 +19,7 @@ void ap_define_true_flag(ap_state_t* pstate, char* flag_name, int* pintv void ap_define_false_flag(ap_state_t* pstate, char* flag_name, int* pintval); void ap_define_int_value_flag(ap_state_t* pstate, char* flag_name, int value, int* pintval); void ap_define_int_flag(ap_state_t* pstate, char* flag_name, int* pintval); +void ap_define_long_long_flag(ap_state_t* pstate, char* flag_name, long long* pintval); void ap_define_float_flag(ap_state_t* pstate, char* flag_name, double* pdoubleval); void ap_define_string_flag(ap_state_t* pstate, char* flag_name, char** pstring); void ap_define_string_list_flag(ap_state_t* pstate, char* flag_name, slls_t** pplist); diff --git a/c/todo.txt b/c/todo.txt index 20d0f1311..3af0d306b 100644 --- a/c/todo.txt +++ b/c/todo.txt @@ -11,6 +11,9 @@ BUGFIXES ================================================================ TOP-OF-LIST SUMMARY +! feature: record-repeater w/ key field(s). UT & mld. +! feature: stats1 weighted by count (or other) field? + ? make a 3.5.0 with nest, shuffle, put/filter -f, cat -n bugfix, etc.? after valgrinds ... * rh/fedora/centos mlr-3.4.0 @@ -37,9 +40,6 @@ TOP-OF-LIST SUMMARY * dsls deps still not quite right? * faqent re nidx output: '$9 = ...' doesn't make it the 9th output field. -! feature: stats1 weighted by count (or other) field? -! feature: record-repeater w/ key field(s)? - ================================================================ * relcut material since 3.4.0: BIG: diff --git a/doc/mlr.1 b/doc/mlr.1 index 4f2f777e1..92a15da86 100644 --- a/doc/mlr.1 +++ b/doc/mlr.1 @@ -854,8 +854,10 @@ mlr reorder -e -f a,b sends input record "d=4,b=2,a=1,c=3" to "d=4,c=3,a=1,b=2". .\} .nf Usage: mlr repeat [options] --f {field name} xxx put my description here please -xxx describe me please. +Copies input records to output records multiple times. +-n {repeat count} Repeat each input record this many times. +-f {field name} Same, but take the repeat count from the specified field name + of each input record. .fi .if n \{\ .RE