diff --git a/fimfarchive/commands/root.py b/fimfarchive/commands/root.py index 6f9d7b8..3f6611d 100644 --- a/fimfarchive/commands/root.py +++ b/fimfarchive/commands/root.py @@ -93,6 +93,9 @@ class RootCommand(Command): 'Fimfarchive, ensuring that history is preseved.\n\n', ] + if not self.commands: + return ''.join(text).strip() + commands = sorted(cmd for cmd in self.commands.keys()) adjust = max(len(cmd) for cmd in commands) + 2 diff --git a/tests/commands/test_root.py b/tests/commands/test_root.py index 22d323b..d98b2aa 100644 --- a/tests/commands/test_root.py +++ b/tests/commands/test_root.py @@ -108,6 +108,13 @@ class TestRootCommanad(): assert "failure Command that returns 1." in doc assert "truncated documentation line" not in doc + def test_root_usage_without_commands(self, root): + """ + Tests usage contains text when no commands are available. + """ + type(root).commands = dict() + assert root.usage.strip() + def test_root_call_without_args(self, root, success, failure): """ Tests `SystemExit` is raised if called without arguments.