TW-188: short help text

- Thanks to David Patrick.
This commit is contained in:
Paul Beckingham 2016-02-01 18:38:14 -05:00
parent ba957344ef
commit 32cf553d4e
4 changed files with 30 additions and 10 deletions

View file

@ -2,6 +2,7 @@
- TW-38 Dates in the far future give bad estimates in burndown - TW-38 Dates in the far future give bad estimates in burndown
(thanks to Ben Boeckel). (thanks to Ben Boeckel).
- TW-188 short help text (thanks to David Patrick).
- TW-311 Estimated completion in burndown.daily shows impossible results - TW-311 Estimated completion in burndown.daily shows impossible results
(thanks to Michele Santullo). (thanks to Michele Santullo).
- TW-1313 some recurring intervals reset due time to midnight - TW-1313 some recurring intervals reset due time to midnight

7
NEWS
View file

@ -1,11 +1,14 @@
New Features in Taskwarrior 2.5.1 New Features in Taskwarrior 2.5.1
- None, this is a bug-fix, code cleanup and performance release only. - As a bug-fix, code cleanup and performance release, new features are
limited to only small tweaks.
- The 'help' command now takes a 'usage' argument, which displays only the
command usage.
New Commands in Taskwarrior 2.5.1 New Commands in Taskwarrior 2.5.1
- None, this is a bug-fix, code cleanup and performance release only. - None.
New Configuration Options in Taskwarrior 2.5.1 New Configuration Options in Taskwarrior 2.5.1

View file

@ -32,6 +32,7 @@
#include <i18n.h> #include <i18n.h>
#include <text.h> #include <text.h>
#include <util.h> #include <util.h>
#include <iostream> // TODO Remove
extern Context context; extern Context context;
@ -39,7 +40,7 @@ extern Context context;
CmdHelp::CmdHelp () CmdHelp::CmdHelp ()
{ {
_keyword = "help"; _keyword = "help";
_usage = "task help"; _usage = "task help ['usage']";
_description = STRING_CMD_HELP_USAGE; _description = STRING_CMD_HELP_USAGE;
_read_only = true; _read_only = true;
_displays_id = false; _displays_id = false;
@ -47,12 +48,29 @@ CmdHelp::CmdHelp ()
_uses_context = false; _uses_context = false;
_accepts_filter = false; _accepts_filter = false;
_accepts_modifications = false; _accepts_modifications = false;
_accepts_miscellaneous = false; _accepts_miscellaneous = true;
_category = Command::Category::misc; _category = Command::Category::misc;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int CmdHelp::execute (std::string& output) int CmdHelp::execute (std::string& output)
{
auto words = context.cli2.getWords ();
if (words.size () == 1 && closeEnough ("usage", words[0]))
output = "\n"
+ composeUsage ()
+ "\n";
else
output = "\n"
+ composeUsage ()
+ "\n"
+ STRING_CMD_HELP_TEXT;
return 0;
}
////////////////////////////////////////////////////////////////////////////////
std::string CmdHelp::composeUsage () const
{ {
ViewText view; ViewText view;
view.width (context.getWidth ()); view.width (context.getWidth ());
@ -110,12 +128,7 @@ int CmdHelp::execute (std::string& output)
} }
} }
output = "\n" return view.render ();
+ view.render ()
+ "\n"
+ STRING_CMD_HELP_TEXT;
return 0;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View file

@ -35,6 +35,9 @@ class CmdHelp : public Command
public: public:
CmdHelp (); CmdHelp ();
int execute (std::string&); int execute (std::string&);
private:
std::string composeUsage () const;
}; };
#endif #endif