mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
'-h' should show help
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
This commit is contained in:
parent
6bb4f981cb
commit
037550b791
3 changed files with 26 additions and 7 deletions
|
@ -1,6 +1,6 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2006 - 2016, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2006 - 2019, Thomas Lauf, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -445,10 +445,9 @@ void CLI::canonicalizeNames ()
|
|||
alreadyFoundCmd = true;
|
||||
}
|
||||
|
||||
// 'timew <command> --help' should be treated the same as 'timew help
|
||||
// <command>'. Therefore, "--help" on the command line should always
|
||||
// become the command.
|
||||
else if (alreadyFoundCmd && (raw == "--help"))
|
||||
// 'timew <command> --help|-h' should be treated the same as 'timew help <command>'.
|
||||
// Therefore, '--help|-h' on the command line should always become the command.
|
||||
else if (alreadyFoundCmd && (raw == "--help" || raw == "-h"))
|
||||
{
|
||||
for (auto& b : _args) {
|
||||
if (b.hasTag("CMD"))
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2016 - 2018, Thomas Lauf, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2016 - 2019, Thomas Lauf, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -62,6 +62,7 @@ void initializeEntities (CLI& cli)
|
|||
cli.entity ("command", "get");
|
||||
cli.entity ("command", "help");
|
||||
cli.entity ("command", "--help");
|
||||
cli.entity ("command", "-h");
|
||||
cli.entity ("command", "join");
|
||||
cli.entity ("command", "lengthen");
|
||||
cli.entity ("command", "modify");
|
||||
|
@ -273,7 +274,8 @@ int dispatchCommand (
|
|||
else if (command == "gaps") status = CmdGaps (cli, rules, database );
|
||||
else if (command == "get") status = CmdGet (cli, rules, database );
|
||||
else if (command == "help" ||
|
||||
command == "--help") status = CmdHelp (cli, extensions);
|
||||
command == "--help" ||
|
||||
command == "-h") status = CmdHelp (cli, extensions);
|
||||
else if (command == "join") status = CmdJoin (cli, rules, database );
|
||||
else if (command == "lengthen") status = CmdLengthen (cli, rules, database );
|
||||
else if (command == "modify") status = CmdModify (cli, rules, database );
|
||||
|
|
18
test/help.t
18
test/help.t
|
@ -46,6 +46,18 @@ class TestHelp(TestCase):
|
|||
code, out, err = self.t("help")
|
||||
self.assertRegexpMatches(out, r"Usage: timew [--version]")
|
||||
|
||||
def test_help_long_option_should_print_usage(self):
|
||||
"""timew --help should print usage"""
|
||||
code, out1, err1 = self.t("help")
|
||||
code, out2, err2 = self.t("--help")
|
||||
self.assertEquals(out1, out2)
|
||||
|
||||
def test_help_short_option_should_print_usage(self):
|
||||
"""timew -h should print usage"""
|
||||
code, out1, err1 = self.t("help")
|
||||
code, out2, err2 = self.t("-h")
|
||||
self.assertEquals(out1, out2)
|
||||
|
||||
def test_help_with_command_should_show_help_page(self):
|
||||
"""timew help with command should show help page"""
|
||||
code, out, err = self.t("help start")
|
||||
|
@ -62,6 +74,12 @@ class TestHelp(TestCase):
|
|||
code, out2, err2 = self.t("track --help")
|
||||
self.assertEquals(out1, out2)
|
||||
|
||||
def test_command_with_help_short_option_should_show_help_page(self):
|
||||
"""timew command with -h should show help page"""
|
||||
code, out1, err1 = self.t("help track")
|
||||
code, out2, err2 = self.t("track -h")
|
||||
self.assertEquals(out1, out2)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from simpletap import TAPTestRunner
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue