hare

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

commit 2b5fde226458613c1226410fadeb9bede06e6563
parent c34cc1d53b783a960d85892837430dfa90f4885c
Author: Drew DeVault <sir@cmpwn.com>
Date:   Sat, 10 Jul 2021 16:21:35 -0400

cmd/hare: rework 'hare version' command

Signed-off-by: Drew DeVault <sir@cmpwn.com>

Diffstat:
Mcmd/hare/subcmds.ha | 40++++++++++++++++++++++++++++------------
1 file changed, 28 insertions(+), 12 deletions(-)

diff --git a/cmd/hare/subcmds.ha b/cmd/hare/subcmds.ha @@ -399,19 +399,35 @@ fn test(args: []str) void = { }; fn version(args: []str) void = { - fmt::printfln("Hare version {}", VERSION)!; - fmt::errorln()!; - fmt::printf("Build tags\t")!; - const tags = default_tags(); - for (let i = 0z; i < len(tags); i += 1) { - const tag = tags[i]; - const inclusive = (tag.mode & module::tag_mode::INCLUSIVE) == module::tag_mode::INCLUSIVE; - fmt::printf("{}{}", if (inclusive) '+' else '-', tag.name)!; + const help: []getopt::help = [ + "provides version information for the Hare environment", + ('v', "print more information"), + ]; + const cmd = getopt::parse(args, help...); + defer getopt::finish(&cmd); + + let verbose = false; + for (let i = 0z; i < len(cmd.opts); i += 1) { + // The only option is verbose + verbose = true; }; - fmt::println()!; - match (os::getenv("HAREPATH")) { - void => fmt::printfln("HAREPATH\t{}", HAREPATH)!, - s: str => fmt::printfln("HAREPATH\t{}\t(from environment)", s)!, + fmt::printfln("Hare {}", VERSION)!; + + if (verbose) { + fmt::errorln()!; + fmt::printf("Build tags\t")!; + const tags = default_tags(); + for (let i = 0z; i < len(tags); i += 1) { + const tag = tags[i]; + const inclusive = (tag.mode & module::tag_mode::INCLUSIVE) == 0; + fmt::printf("{}{}", if (inclusive) '+' else '-', tag.name)!; + }; + fmt::println()!; + + match (os::getenv("HAREPATH")) { + void => fmt::printfln("HAREPATH\t{}", HAREPATH)!, + s: str => fmt::printfln("HAREPATH\t{}\t(from environment)", s)!, + }; }; };