hare

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

commit 3ab51bad39f641116c83998d273546d0a3cd4144
parent 130d4b9a62df5a45cd6da721d7e99cb307752404
Author: Eyal Sawady <ecs@d2evs.net>
Date:   Sat,  4 Sep 2021 00:39:32 +0000

cmd/haredoc: -Ftty, -Fhare: drop trailing newline

Signed-off-by: Eyal Sawady <ecs@d2evs.net>

Diffstat:
Mcmd/haredoc/hare.ha | 21+++++++++++++++++++--
Mcmd/haredoc/tty.ha | 21+++++++++++++++++++--
2 files changed, 38 insertions(+), 4 deletions(-)

diff --git a/cmd/haredoc/hare.ha b/cmd/haredoc/hare.ha @@ -12,8 +12,10 @@ use strio; fn emit_hare(ctx: *context) (void | error) = { const summary = ctx.summary; + let first = true; match (ctx.readme) { readme: *io::stream => { + first = false; for (true) match (bufio::scanline(readme)?) { b: []u8 => { fmt::printfln("// {}", strings::fromutf8(b))?; @@ -21,22 +23,37 @@ fn emit_hare(ctx: *context) (void | error) = { }, io::EOF => break, }; - fmt::println()?; }, null => void, }; // XXX: Should we emit the dependencies, too? for (let i = 0z; i < len(summary.types); i += 1) { + if (!first) { + fmt::println()?; + }; + first = false; details_hare(ctx, summary.types[i])?; }; for (let i = 0z; i < len(summary.errors); i += 1) { + if (!first) { + fmt::println()?; + }; + first = false; details_hare(ctx, summary.errors[i])?; }; for (let i = 0z; i < len(summary.globals); i += 1) { + if (!first) { + fmt::println()?; + }; + first = false; details_hare(ctx, summary.globals[i])?; }; for (let i = 0z; i < len(summary.funcs); i += 1) { + if (!first) { + fmt::println()?; + }; + first = false; details_hare(ctx, summary.funcs[i])?; }; }; @@ -55,7 +72,7 @@ fn details_hare(ctx: *context, decl: ast::decl) (void | error) = { }; unparse_hare(os::stdout, decl)?; - fmt::print("\n\n")?; + fmt::println()?; return; }; diff --git a/cmd/haredoc/tty.ha b/cmd/haredoc/tty.ha @@ -12,8 +12,10 @@ use strio; fn emit_tty(ctx: *context) (void | error) = { const summary = ctx.summary; + let first = true; match (ctx.readme) { readme: *io::stream => { + first = false; for (true) match (bufio::scanline(readme)?) { b: []u8 => { fmt::printfln( @@ -23,22 +25,37 @@ fn emit_tty(ctx: *context) (void | error) = { }, io::EOF => break, }; - fmt::println()?; }, null => void, }; // XXX: Should we emit the dependencies, too? for (let i = 0z; i < len(summary.types); i += 1) { + if (!first) { + fmt::println()?; + }; + first = false; details_tty(ctx, summary.types[i])?; }; for (let i = 0z; i < len(summary.errors); i += 1) { + if (!first) { + fmt::println()?; + }; + first = false; details_tty(ctx, summary.errors[i])?; }; for (let i = 0z; i < len(summary.globals); i += 1) { + if (!first) { + fmt::println()?; + }; + first = false; details_tty(ctx, summary.globals[i])?; }; for (let i = 0z; i < len(summary.funcs); i += 1) { + if (!first) { + fmt::println()?; + }; + first = false; details_tty(ctx, summary.funcs[i])?; }; }; @@ -57,7 +74,7 @@ fn details_tty(ctx: *context, decl: ast::decl) (void | error) = { }; unparse_tty(os::stdout, decl)?; - fmt::print("\n\n")?; + fmt::println()?; return; };