From db8639b893528f0aa619914b93d5d8ed03d532e9 Mon Sep 17 00:00:00 2001 From: Luka Vandervelden Date: Tue, 15 Dec 2020 10:06:13 +0100 Subject: [PATCH] Commands implemented through OptionsParser. --- src/main.cr | 82 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 55 insertions(+), 27 deletions(-) diff --git a/src/main.cr b/src/main.cr index 6882ed7..ba0ca32 100644 --- a/src/main.cr +++ b/src/main.cr @@ -37,6 +37,19 @@ module Baguette::Base include Baguette::Log end +class OptionParser + def to_s(io : IO) : Nil + if banner = @banner + io << banner << '\n' + end + + @flags.select(&.starts_with? " -").join io, '\n' + + io << "\ncommands:\n" + @flags.select{ |x| !x.starts_with? " -" }.join io, '\n' + end +end + Colorize.on_tty_only! # CAUTION @@ -50,71 +63,86 @@ class RootFS::Context @configuration = Baguette::Configuration.new "rootfs" end - def print_commands_help - STDOUT << "commands:" << "\n" - STDOUT << " new