lib

morphux C utility library
Log | Files | Refs | Submodules | README | LICENSE | git clone https://git.ne02ptzero.me/git/lib

commit 42dc223c15d47d95df206655a79d91484f4bcd26
parent 7f345ccbafa387f189d2007367f9c504efb5d5b1
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Wed, 26 Jul 2017 16:44:58 +0200

Fix(Args): Now can print only-word option in help:

Slight rework of the fors

Diffstat:
Msrc/m_args.c | 15++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/m_args.c b/src/m_args.c @@ -186,17 +186,26 @@ void opt_help(const mopts_t *opts, u8_t ret) { usage(opts); m_info("Help:\n"); - for (u32_t i = 0; opts[i].opt != 0; i++) + for (u32_t i = 0; !IS_EOL(opts[i]); i++) { if (opts[i].s_opt != NULL && (strlen(opts[i].s_opt) + 2) > pad) pad = strlen(opts[i].s_opt) + 6; } - for (u32_t i = 0; opts[i].opt != 0; i++) + for (u32_t i = 0; !IS_EOL(opts[i]); i++) { if (opts[i].s_opt != NULL) - m_info("\t-%c, --%s%*s%s\n", opts[i].opt, opts[i].s_opt, pad - (strlen(opts[i].s_opt)), "", opts[i].desc); + { + if (opts[i].opt != 0) + m_info("\t-%c, ", opts[i].opt); + else + m_info("\t "); + + fprintf(stdout, "--%s%*s%s\n", opts[i].s_opt, (int)(pad - (strlen(opts[i].s_opt))), "", opts[i].desc); + } else + { m_info("\t-%c%*s%s\n", opts[i].opt, pad + 4, "", opts[i].desc); + } } m_info("\t-%c, --%s%*s%s\n", LIB_OPT_TOKEN_HELP, LIB_OPT_STRING_HELP, pad - (strlen(LIB_OPT_STRING_HELP)), "", "Show this help");