Skip to content

Commit 5530bab

Browse files
authored
fix(cli[sync]): Fix vcspull sync with no args (#405)
2 parents efb0bf7 + 3446bf9 commit 5530bab

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
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.5 (unreleased)
25+
26+
### CLI
27+
28+
- `vcspull sync`: Fix showing of help when no arguments passed (#405)
29+
2430
## vcspull v1.15.4 (2022-10-16)
2531

2632
### CLI

src/vcspull/cli/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def create_parser():
3030
default="INFO",
3131
help="log level (DEBUG, INFO, WARNING, ERROR, CRITICAL)",
3232
)
33+
3334
subparsers = parser.add_subparsers(dest="subparser_name")
3435
sync_parser = subparsers.add_parser("sync", help="synchronize repos")
3536
create_sync_subparser(sync_parser)

src/vcspull/cli/sync.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def create_sync_subparser(parser: argparse.ArgumentParser) -> argparse.ArgumentP
2424
config_file = parser.add_argument("--config", "-c", help="specify config")
2525
parser.add_argument(
2626
"repo_terms",
27-
nargs="+",
27+
nargs="*",
2828
help="filters: repo terms, separated by spaces, supports globs / fnmatch (1)",
2929
)
3030
parser.add_argument(
@@ -34,6 +34,7 @@ def create_sync_subparser(parser: argparse.ArgumentParser) -> argparse.ArgumentP
3434
dest="exit_on_error",
3535
help="exit immediately when encountering an error syncing multiple repos",
3636
)
37+
3738
try:
3839
import shtab
3940

@@ -51,6 +52,11 @@ def sync(
5152
argparse.ArgumentParser
5253
] = None, # optional so sync can be unit tested
5354
) -> None:
55+
if isinstance(repo_terms, list) and len(repo_terms) == 0:
56+
if parser is not None:
57+
parser.print_help()
58+
sys.exit(2)
59+
5460
if config:
5561
configs = load_configs([config])
5662
else:

tests/test_cli.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,8 @@ class SyncFixture(t.NamedTuple):
157157
SyncFixture(
158158
test_id="sync--empty",
159159
sync_args=["sync"],
160-
expected_exit_code=1,
161-
expected_in_out=(
162-
"sync: error: the following arguments are required: repo_terms"
163-
),
164-
expected_not_in_out="positional arguments:",
160+
expected_exit_code=0,
161+
expected_in_out=["positional arguments:"],
165162
),
166163
# Sync: Help
167164
SyncFixture(

0 commit comments

Comments
 (0)