From c870347f749664c94606020fe262bc2809ccfe19 Mon Sep 17 00:00:00 2001 From: torque Date: Thu, 23 Mar 2023 01:02:54 -0700 Subject: [PATCH] noclip: improve help generation formatting There are still quirks here. It's worth deciding if help descriptions should be automatically hard-wrapped. Multi-line descriptions require appropriate indentation after the first line. Long descriptions will automatically be wrapped by the terminal. The refactoring itch continues to grow. --- source/noclip.zig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/noclip.zig b/source/noclip.zig index cbd212e..44af794 100644 --- a/source/noclip.zig +++ b/source/noclip.zig @@ -304,9 +304,12 @@ pub fn CommandParser( ); try writer.writeAll(data.help); + if (!std.mem.endsWith(u8, data.help, "\n")) { + try writer.writeAll("\n"); + } if (param_count.args > 0) { - try writer.writeAll("\n\nArguments:\n"); + try writer.writeAll("\nArguments:\n"); for (args) |arg| { defer arg.deinit(alloc);