diff --git a/changelogs/fragments/69458-updated-galaxy-cli-help.yaml b/changelogs/fragments/69458-updated-galaxy-cli-help.yaml new file mode 100644 index 00000000000..6991a4827bb --- /dev/null +++ b/changelogs/fragments/69458-updated-galaxy-cli-help.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: + - "ansible-galaxy- On giving an invalid subcommand to ansible-galaxy, the help would be shown only for role subcommand (collection subcommand help is not shown). With this change, the entire help for ansible-galaxy (same as ansible-galaxy --help) is displayed along with the help for role subcommand. (https://github.com/ansible/ansible/issues/69009)" \ No newline at end of file diff --git a/lib/ansible/cli/__init__.py b/lib/ansible/cli/__init__.py index 59b19c636ff..e8b72f419d9 100644 --- a/lib/ansible/cli/__init__.py +++ b/lib/ansible/cli/__init__.py @@ -372,7 +372,12 @@ class CLI(with_metaclass(ABCMeta, object)): if HAS_ARGCOMPLETE: argcomplete.autocomplete(self.parser) - options = self.parser.parse_args(self.args[1:]) + try: + options = self.parser.parse_args(self.args[1:]) + except SystemExit as e: + if(e.code != 0): + self.parser.exit(status=2, message=" \n%s " % self.parser.format_help()) + raise options = self.post_process_args(options) context._init_global_context(options)