hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit dfcb33c94086296d35091a125df999bf3e008eaf
parent 337e579ccc4d91f7be4646cd4759312b65ee331b
Author: Drew DeVault <sir@cmpwn.com>
Date:   Thu, 11 Mar 2021 12:31:29 -0500

getopt: suppress extra newline for flagless cmd

Diffstat:
Mgetopt/getopts.ha | 9++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/getopt/getopts.ha b/getopt/getopts.ha @@ -232,7 +232,14 @@ export fn print_help(s: *io::stream, name: str, help: []help) void = { print_usage(s, name, help); - fmt::fprint(s, "\n"); + for (let i = 0z; i < len(help); i += 1) match (help[i]) { + cmd_help => void, + (flag_help | parameter_help) => { + // Only print this if there are flags to show + fmt::fprint(s, "\n"); + break; + }, + }; for (let i = 0z; i < len(help); i += 1) match (help[i]) { cmd_help => void,