Skip to content

Commit b5e4896

Browse files
committed
fix(cli): Show subparser-specific help text
1 parent 7792eae commit b5e4896

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

src/vcspull/cli/__init__.py

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,25 @@
1616

1717
log = logging.getLogger(__name__)
1818

19+
SYNC_DESCRIPTION = textwrap.dedent(
20+
"""
21+
sync vcs repos
22+
23+
examples:
24+
vcspull sync "*"
25+
vcspull sync "django-*"
26+
vcspull sync "django-*" flask
27+
vcspull sync -c ./myrepos.yaml "*"
28+
vcspull sync -c ./myrepos.yaml myproject
29+
"""
30+
).strip()
31+
1932

2033
def create_parser():
2134
parser = argparse.ArgumentParser(
2235
prog="vcspull",
2336
formatter_class=argparse.RawDescriptionHelpFormatter,
24-
description=textwrap.dedent(
25-
"""
26-
sync vcs repos
27-
28-
examples:
29-
vcspull sync "*"
30-
vcspull sync "django-*"
31-
vcspull sync "django-*" flask
32-
vcspull sync -c ./myrepos.yaml "*"
33-
vcspull sync -c ./myrepos.yaml myproject
34-
"""
35-
).strip(),
37+
description=SYNC_DESCRIPTION,
3638
)
3739
parser.add_argument(
3840
"--version",
@@ -49,14 +51,19 @@ def create_parser():
4951
)
5052

5153
subparsers = parser.add_subparsers(dest="subparser_name")
52-
sync_parser = subparsers.add_parser("sync", help="synchronize repos")
54+
sync_parser = subparsers.add_parser(
55+
"sync",
56+
help="synchronize repos",
57+
formatter_class=argparse.RawDescriptionHelpFormatter,
58+
description=SYNC_DESCRIPTION,
59+
)
5360
create_sync_subparser(sync_parser)
5461

55-
return parser
62+
return parser, sync_parser
5663

5764

5865
def cli(args=None):
59-
parser = create_parser()
66+
parser, sync_parser = create_parser()
6067
args = parser.parse_args(args)
6168

6269
setup_logger(log=log, level=args.log_level.upper())
@@ -69,5 +76,5 @@ def cli(args=None):
6976
repo_terms=args.repo_terms,
7077
config=args.config,
7178
exit_on_error=args.exit_on_error,
72-
parser=parser,
79+
parser=sync_parser,
7380
)

0 commit comments

Comments
 (0)