Skip to content

Commit 6d484c1

Browse files
authored
refactor(cli): Copy tweaks to frontend (#407)
2 parents 1727c8a + 7fac057 commit 6d484c1

File tree

4 files changed

+43
-23
lines changed

4 files changed

+43
-23
lines changed

CHANGES

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ $ pipx install --suffix=@next 'vcspull' --pip-args '\--pre' --force
2121

2222
<!-- Maintainers, insert changes / features for the next release here -->
2323

24+
## vcspull v1.15.7 (unreleased)
25+
26+
### CLI
27+
28+
- `vcspull` and `vcspull sync` Copy updates and metavar updates (#404)
29+
2430
## vcspull v1.15.6 (2022-10-16)
2531

2632
### CLI

src/vcspull/cli/__init__.py

Lines changed: 25 additions & 17 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 vcspull 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",
@@ -42,20 +44,26 @@ def create_parser():
4244
)
4345
parser.add_argument(
4446
"--log-level",
47+
metavar="level",
4548
action="store",
4649
default="INFO",
47-
help="log level (DEBUG, INFO, WARNING, ERROR, CRITICAL)",
50+
help="log level (debug, info, warning, error, critical)",
4851
)
4952

5053
subparsers = parser.add_subparsers(dest="subparser_name")
51-
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+
)
5260
create_sync_subparser(sync_parser)
5361

54-
return parser
62+
return parser, sync_parser
5563

5664

5765
def cli(args=None):
58-
parser = create_parser()
66+
parser, sync_parser = create_parser()
5967
args = parser.parse_args(args)
6068

6169
setup_logger(log=log, level=args.log_level.upper())
@@ -68,5 +76,5 @@ def cli(args=None):
6876
repo_terms=args.repo_terms,
6977
config=args.config,
7078
exit_on_error=args.exit_on_error,
71-
parser=parser,
79+
parser=sync_parser,
7280
)

src/vcspull/cli/sync.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,24 @@ def clamp(n, _min, _max):
2121

2222

2323
def create_sync_subparser(parser: argparse.ArgumentParser) -> argparse.ArgumentParser:
24-
config_file = parser.add_argument("--config", "-c", help="specify config")
24+
config_file = parser.add_argument(
25+
"--config",
26+
"-c",
27+
metavar="config-file",
28+
help="optional filepath to specify vcspull config",
29+
)
2530
parser.add_argument(
2631
"repo_terms",
32+
metavar="filter",
2733
nargs="*",
28-
help="filters: repo terms, separated by spaces, supports globs / fnmatch (1)",
34+
help="patterns / terms of repos, accepts globs / fnmatch(3)",
2935
)
3036
parser.add_argument(
3137
"--exit-on-error",
3238
"-x",
3339
action="store_true",
3440
dest="exit_on_error",
35-
help="exit immediately when encountering an error syncing multiple repos",
41+
help="exit immediately encountering error (when syncing multiple repos)",
3642
)
3743

3844
try:

tests/test_cli.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class SyncCLINonExistentRepo(t.NamedTuple):
5959
SYNC_CLI_EXISTENT_REPO_FIXTURES,
6060
ids=[test.test_id for test in SYNC_CLI_EXISTENT_REPO_FIXTURES],
6161
)
62-
def test_sync_cli_repo_term_non_existent(
62+
def test_sync_cli_filter_non_existent(
6363
tmp_path: pathlib.Path,
6464
capsys: pytest.CaptureFixture,
6565
monkeypatch: pytest.MonkeyPatch,
@@ -165,14 +165,14 @@ class SyncFixture(t.NamedTuple):
165165
test_id="sync---help",
166166
sync_args=["sync", "--help"],
167167
expected_exit_code=0,
168-
expected_in_out=["repo_terms", "--exit-on-error"],
168+
expected_in_out=["filter", "--exit-on-error"],
169169
expected_not_in_out="--version",
170170
),
171171
SyncFixture(
172172
test_id="sync--h",
173173
sync_args=["sync", "-h"],
174174
expected_exit_code=0,
175-
expected_in_out=["repo_terms", "--exit-on-error"],
175+
expected_in_out=["filter", "--exit-on-error"],
176176
expected_not_in_out="--version",
177177
),
178178
# Sync: Repo terms

0 commit comments

Comments
 (0)