diff --git a/cms/management/commands/subcommands/base.py b/cms/management/commands/subcommands/base.py index 6bfefcc9025..4ee218b0f6c 100644 --- a/cms/management/commands/subcommands/base.py +++ b/cms/management/commands/subcommands/base.py @@ -60,6 +60,8 @@ def create_parser(self, prog_name, subcommand): parser = CommandParser( prog=f"{os.path.basename(prog_name)} {subcommand}", description=self.help or None, + missing_args_message=getattr(self, "missing_args_message", None), + called_from_command_line=getattr(self, "_called_from_command_line", None), **kwargs ) self.add_arguments(parser) diff --git a/cms/tests/test_management.py b/cms/tests/test_management.py index e4ebee6ed8a..eb723c620f0 100644 --- a/cms/tests/test_management.py +++ b/cms/tests/test_management.py @@ -304,6 +304,10 @@ def test_uninstall_plugins_with_plugin(self): self.assertEqual(out.getvalue(), "1 'TextPlugin' plugins uninstalled\n") self.assertEqual(CMSPlugin.objects.filter(plugin_type=PLUGIN).count(), 0) + def test_for_running_only_cms_command(self): + with self.assertRaises(CommandError) as e: + management.call_command('cms') + self.assertEqual(str(e.exception), 'Error: one of the available sub commands must be provided') class PageFixtureManagementTestCase(NavextendersFixture, CMSTestCase):