Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions doc/man/task.1.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ task \- A command line todo manager.
.SH SYNOPSIS
.B task <filter> <command> [ <mods> | <args> ]
.br
.B task --help
.br
.B task --version

.SH DESCRIPTION
Expand Down Expand Up @@ -126,11 +128,15 @@ Taskwarrior. The output and sort behavior of these reports can be configured in
the configuration file. See also the man page taskrc(5). There are also other
read subcommands that are not reports.

.TP
.B task --help
Displays the same usage and command documentation as the 'task help' command.

.TP
.B task --version
This is the only conventional command line argument that Taskwarrior supports,
and is intended for add-on scripts to verify the version number of an installed
Taskwarrior without invoking the mechanisms that create default files.
This command line argument is intended for add-on scripts to verify the version
number of an installed Taskwarrior without invoking the mechanisms that create
default files.

.TP
.B task <filter>
Expand Down
5 changes: 5 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ int main(int argc, const char** argv) {
Context globalContext;
Context::setContext(&globalContext);

// Reuse the existing help command instead of maintaining separate output.
if (argc == 2 && !strcmp(argv[1], "--help")) {
argv[1] = "help";
}

// Lightweight version checking that doesn't require initialization or any I/O.
if (argc == 2 && !strcmp(argv[1], "--version")) {
std::cout << VERSION << "\n";
Expand Down
9 changes: 9 additions & 0 deletions test/commands.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ class TestCommands(TestCase):
def setUp(self):
self.t = Task()

def test_help_option(self):
"""Verify '--help' is equivalent to the help command"""
_, help_out, help_err = self.t("help")
_, option_out, option_err = self.t("--help")

self.assertIn("Usage:", option_out)
self.assertEqual(option_out, help_out)
self.assertEqual(option_err, help_err)

def test_command_dna(self):
"""Verify 'add', 'modify', 'list' dna"""
code, out, err = self.t("commands")
Expand Down
Loading