From 7bd04ebfc740426f89e2444466eebadc73616c5a Mon Sep 17 00:00:00 2001 From: Yurii Bakurov <45154988+Yurii201811@users.noreply.github.com> Date: Mon, 13 Jul 2026 15:40:49 +0200 Subject: [PATCH 1/2] Add support for --help --- doc/man/task.1.in | 12 +++++++++--- src/main.cpp | 3 +++ test/commands.test.py | 8 ++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) 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..b1d1a6723 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -47,6 +47,9 @@ int main(int argc, const char** argv) { Context globalContext; Context::setContext(&globalContext); + // Support the conventional help option through the existing help command. + 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..79f0e5c23 100755 --- a/test/commands.test.py +++ b/test/commands.test.py @@ -39,6 +39,14 @@ class TestCommands(TestCase): def setUp(self): self.t = Task() + def test_help_option(self): + """Verify '--help' is equivalent to the help command""" + code, help_out, help_err = self.t("help") + code, option_out, option_err = self.t("--help") + + 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") From ad6a1b3185036bd57987b4594e7a6a040f73114a Mon Sep 17 00:00:00 2001 From: Yurii Bakurov <45154988+Yurii201811@users.noreply.github.com> Date: Tue, 14 Jul 2026 14:46:15 +0200 Subject: [PATCH 2/2] Strengthen --help regression coverage --- src/main.cpp | 6 ++++-- test/commands.test.py | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index b1d1a6723..4dc0baf7a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -47,8 +47,10 @@ int main(int argc, const char** argv) { Context globalContext; Context::setContext(&globalContext); - // Support the conventional help option through the existing help command. - if (argc == 2 && !strcmp(argv[1], "--help")) argv[1] = "help"; + // 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")) { diff --git a/test/commands.test.py b/test/commands.test.py index 79f0e5c23..ed146a679 100755 --- a/test/commands.test.py +++ b/test/commands.test.py @@ -41,9 +41,10 @@ def setUp(self): def test_help_option(self): """Verify '--help' is equivalent to the help command""" - code, help_out, help_err = self.t("help") - code, option_out, option_err = self.t("--help") + _, 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)