From cd71e7f90f9e401ebfb08c1e4bf65a1305980ff8 Mon Sep 17 00:00:00 2001 From: Nicholas O'Connor Date: Thu, 13 Apr 2017 14:35:50 -0700 Subject: [PATCH] hello output::blank_line() (with optional bool) (fixes bug #8 ) --- include/output.hpp | 2 ++ src/help/help.cpp | 6 +++--- src/output.cpp | 6 ++++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/output.hpp b/include/output.hpp index 22bf65b..af1b734 100644 --- a/include/output.hpp +++ b/include/output.hpp @@ -12,6 +12,8 @@ namespace cellar { extern void statement(std::string parm, bool); extern void warning(std::string, bool); extern void error(std::string, bool); + + extern void blank_line(bool verbose = false); extern bool colors; extern void detect_colors(); diff --git a/src/help/help.cpp b/src/help/help.cpp index 7b4918c..d96bfcc 100644 --- a/src/help/help.cpp +++ b/src/help/help.cpp @@ -17,7 +17,7 @@ void cellar::core::help_command(int argc, vector argv) { vector commands = list_commands(); cellar::print_header(); - cout << endl; // TODO: cellar::output function for code clarity + output::blank_line(); if (argc == 1) { output::statement("You have these commands:"); @@ -42,7 +42,7 @@ void cellar::core::help_command(int argc, vector argv) { else { sstr << desc; } output::statement(sstr.str()); - cout << endl; + output::blank_line(); string details = help::get_details(command); if (details.empty()) { output::statement("no details available."); } @@ -52,7 +52,7 @@ void cellar::core::help_command(int argc, vector argv) { for (string line : detaillines) { if (!line.empty()) { output::statement(line); } - else { cout << endl; } + else { output::blank_line(); } } } } diff --git a/src/output.cpp b/src/output.cpp index 5a64e68..679e83f 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -66,3 +66,9 @@ void cellar::output::error(string str_message, bool verbose) { } void cellar::output::error(string str_message) { error(str_message, false); } +void cellar::output::blank_line(bool verbose) { + if (verbose and !cellar::verbose) { return; } + if (colors) { // don't output if not in colors mode, for easier parsing + cout << endl; + } +}