Artifact 09e6f94502eedecccaf6005dbbc572e1e4287b3f81630649be56db288847ecfc:
- File mod/kcli/usage.fn.c — part of check-in [8d6b36fcac] at 2019-10-30 07:44:12 on branch trunk — factor out write buffer code so any module and libk users can call it; update documentation to match; add kssz string length function (user: lexi, size: 406) [annotate] [blame] [check-ins using]
#include <k/cli.h> #include <k/io.h> #include <k/str.h> kcond kcli_usage(kcli_set prg, kiochan ch) { ubyte buf_space [sizeof(ksbuf) + 256]; ksbuf* out = ksbufmk(buf_space, ch, 256); const char* msg [] = { prg.name, " v", prg.version, "\n\n", prg.desc, "\n\n", }; for (sz i = 0; i != Kmsz(msg); ++ i) { ksraw str = { 0, msg[i] }; kcond c = ksbufput(out, str); } return ksbufflush(out); }