Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use only the base name of the program in argparse help #14

Merged
merged 2 commits into from
Jun 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions colcon_alias/argument_parser/alias.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Copyright 2022 Scott K Logan
# Licensed under the Apache License, Version 2.0

import os

from colcon_alias.config import get_config
from colcon_alias.verb.alias_invocation import AliasInvocationVerb
from colcon_core.argument_parser import ArgumentParserDecorator
Expand Down Expand Up @@ -66,11 +68,13 @@ def _add_aliases(self):
if self._done:
return

prog = os.path.basename(self._parser.prog)

add_args_now = False
if not self._subparser:
add_args_now = True
self.add_subparsers(
title='colcon verbs', dest='verb_name')
title=prog + ' verbs', dest='verb_name')

config = get_config()
if not config:
Expand Down Expand Up @@ -105,7 +109,7 @@ def _add_aliases(self):
if add_args_now:
extension.add_arguments(parser=alias_parser)

epilog = self._parser.prog + ' aliases:\n' + '\n'.join(aliases)
epilog = prog + ' aliases:\n' + '\n'.join(aliases)
if self._parser.epilog:
self._parser.epilog = epilog + '\n\n' + self._parser.epilog
else:
Expand Down
Loading