diff --git a/doc/man/task.1.in b/doc/man/task.1.in index bed3c8f3a..407b8ab73 100644 --- a/doc/man/task.1.in +++ b/doc/man/task.1.in @@ -6,6 +6,8 @@ task \- A command line todo manager. .SH SYNOPSIS .B task [ | ] .br +.B task --help +.br .B task --version .SH DESCRIPTION @@ -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 diff --git a/src/main.cpp b/src/main.cpp index b202cd6ad..4dc0baf7a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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"; diff --git a/test/commands.test.py b/test/commands.test.py index acf91a68e..ed146a679 100755 --- a/test/commands.test.py +++ b/test/commands.test.py @@ -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")