Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ $ pipx install --suffix=@next 'vcspull' --pip-args '\--pre' --force

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

## vcspull v1.15.5 (unreleased)

### CLI

- `vcspull sync`: Fix showing of help when no arguments passed (#405)

## vcspull v1.15.4 (2022-10-16)

### CLI
Expand Down
1 change: 1 addition & 0 deletions src/vcspull/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def create_parser():
default="INFO",
help="log level (DEBUG, INFO, WARNING, ERROR, CRITICAL)",
)

subparsers = parser.add_subparsers(dest="subparser_name")
sync_parser = subparsers.add_parser("sync", help="synchronize repos")
create_sync_subparser(sync_parser)
Expand Down
8 changes: 7 additions & 1 deletion src/vcspull/cli/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def create_sync_subparser(parser: argparse.ArgumentParser) -> argparse.ArgumentP
config_file = parser.add_argument("--config", "-c", help="specify config")
parser.add_argument(
"repo_terms",
nargs="+",
nargs="*",
help="filters: repo terms, separated by spaces, supports globs / fnmatch (1)",
)
parser.add_argument(
Expand All @@ -34,6 +34,7 @@ def create_sync_subparser(parser: argparse.ArgumentParser) -> argparse.ArgumentP
dest="exit_on_error",
help="exit immediately when encountering an error syncing multiple repos",
)

try:
import shtab

Expand All @@ -51,6 +52,11 @@ def sync(
argparse.ArgumentParser
] = None, # optional so sync can be unit tested
) -> None:
if isinstance(repo_terms, list) and len(repo_terms) == 0:
if parser is not None:
parser.print_help()
sys.exit(2)

if config:
configs = load_configs([config])
else:
Expand Down
7 changes: 2 additions & 5 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,8 @@ class SyncFixture(t.NamedTuple):
SyncFixture(
test_id="sync--empty",
sync_args=["sync"],
expected_exit_code=1,
expected_in_out=(
"sync: error: the following arguments are required: repo_terms"
),
expected_not_in_out="positional arguments:",
expected_exit_code=0,
expected_in_out=["positional arguments:"],
),
# Sync: Help
SyncFixture(
Expand Down