aboutsummaryrefslogtreecommitdiff
path: root/toys/example/demo_number.c
diff options
context:
space:
mode:
Diffstat (limited to 'toys/example/demo_number.c')
-rw-r--r--toys/example/demo_number.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/toys/example/demo_number.c b/toys/example/demo_number.c
index 010320cf..42b62b51 100644
--- a/toys/example/demo_number.c
+++ b/toys/example/demo_number.c
@@ -2,14 +2,17 @@
*
* Copyright 2015 Rob Landley <rob@landley.net>
-USE_DEMO_NUMBER(NEWTOY(demo_number, "D#=3<3hdbs", TOYFLAG_BIN))
+USE_DEMO_NUMBER(NEWTOY(demo_number, "D#=3<3M#<0hcdbs", TOYFLAG_BIN))
config DEMO_NUMBER
bool "demo_number"
default n
help
- usage: demo_number [-hsbi] NUMBER...
+ usage: demo_number [-hsbi] [-D LEN] NUMBER...
+ -D output field is LEN chars
+ -M input units (index into bkmgtpe)
+ -c Comma comma down do be do down down
-b Use "B" for single byte units (HR_B)
-d Decimal units
-h Human readable
@@ -20,7 +23,7 @@ config DEMO_NUMBER
#include "toys.h"
GLOBALS(
- long D;
+ long M, D;
)
void demo_number_main(void)
@@ -31,7 +34,7 @@ void demo_number_main(void)
long long ll = atolx(*arg);
if (toys.optflags) {
- human_readable_long(toybuf, ll, TT.D, toys.optflags);
+ human_readable_long(toybuf, ll, TT.D, TT.M, toys.optflags);
xputs(toybuf);
} else printf("%lld\n", ll);
}