configuration option to not show help in welcome

This commit is contained in:
Nicolas Tessore 2019-06-29 01:10:40 +01:00
parent 61dd5ea775
commit d48909041d
2 changed files with 25 additions and 13 deletions

View file

@ -143,6 +143,11 @@ The review command storeѕ a UDA ('reviewed') and report definition ('_reviewed'
If set to "1", causes each tasksh command to be preceded by a 'clear screen' and
cursor reset. Default is "0".
.TP
.B tasksh.nohelp=1
If set to "1", tasksh will not show the output of the 'help' command as part of
its welcome message. Default is "0".
.SH "CREDITS & COPYRIGHTS"
Copyright (C) 2006 \- 2017 P. Beckingham, F. Hernandez.

View file

@ -52,9 +52,10 @@ std::string promptCompose ();
std::string findTaskwarrior ();
////////////////////////////////////////////////////////////////////////////////
static void welcome ()
static void welcome (bool noHelp)
{
std::cout << PACKAGE_STRING << "\n";
if (! noHelp)
cmdHelp ();
}
@ -138,6 +139,20 @@ static int commandLoop (bool autoClear)
return status;
}
////////////////////////////////////////////////////////////////////////////////
static bool getBoolFromTaskrc (const std::string& path)
{
std::string input;
std::string output;
execute ("task", {"_get", path}, input, output);
output = lowerCase (output);
return output == "true\n" ||
output == "1\n" ||
output == "y\n" ||
output == "yes\n" ||
output == "on\n" ;
}
////////////////////////////////////////////////////////////////////////////////
int main (int argc, const char** argv)
{
@ -153,19 +168,11 @@ int main (int argc, const char** argv)
try
{
// Get the Taskwarrior rc.tasksh.autoclear Boolean setting.
bool autoClear = false;
std::string input;
std::string output;
execute ("task", {"_get", "rc.tasksh.autoclear"}, input, output);
output = lowerCase (output);
autoClear = (output == "true\n" ||
output == "1\n" ||
output == "y\n" ||
output == "yes\n" ||
output == "on\n");
bool autoClear = getBoolFromTaskrc("rc.tasksh.autoclear");
bool noHelp = getBoolFromTaskrc("rc.tasksh.nohelp");
if (isatty (fileno (stdin)))
welcome ();
welcome (noHelp);
while ((status = commandLoop (autoClear)) == 0)
;