Beautify usage
This commit is contained in:
15
src/option.c
15
src/option.c
@@ -94,18 +94,18 @@ static int option_usage (struct option *opts, int slen)
|
|||||||
if (!opts)
|
if (!opts)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int len = slen;
|
int len = 0;
|
||||||
|
|
||||||
for (int k=0; opts[k].name; k++) {
|
for (int k=0; opts[k].name; k++) {
|
||||||
if (len>slen+40) {
|
if (len>40) {
|
||||||
gt_print("\n%*s", (int)slen, "");
|
gt_print("\n%*s", slen, "");
|
||||||
len = slen;
|
len = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
len += gt_print(" [%s", opts[k].name);
|
len += gt_print(" [%s", opts[k].name);
|
||||||
|
|
||||||
if (opts[k].call==option_option) {
|
if (opts[k].call==option_option) {
|
||||||
len += option_usage((struct option *)opts[k].data, len);
|
len += option_usage((struct option *)opts[k].data, slen+len);
|
||||||
} else {
|
} else {
|
||||||
len += gt_print(" ARG");
|
len += gt_print(" ARG");
|
||||||
}
|
}
|
||||||
@@ -132,12 +132,11 @@ int option (struct option *opts, int argc, char **argv)
|
|||||||
|
|
||||||
if (slen>40) {
|
if (slen>40) {
|
||||||
slen = 12;
|
slen = 12;
|
||||||
gt_print("\n%*s", (int)slen, "");
|
gt_print("\n%*s", slen, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
option_usage(opts, slen);
|
option_usage(opts, slen);
|
||||||
|
gt_print("\n");
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user