libk  Artifact [09e6f94502]

Artifact 09e6f94502eedecccaf6005dbbc572e1e4287b3f81630649be56db288847ecfc:


#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);
}