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.7 (unreleased)

### CLI

- `vcspull` and `vcspull sync` Copy updates and metavar updates (#404)

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

### CLI
Expand Down
42 changes: 25 additions & 17 deletions src/vcspull/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,25 @@

log = logging.getLogger(__name__)

SYNC_DESCRIPTION = textwrap.dedent(
"""
sync vcs repos

examples:
vcspull sync "*"
vcspull sync "django-*"
vcspull sync "django-*" flask
vcspull sync -c ./myrepos.yaml "*"
vcspull sync -c ./myrepos.yaml myproject
"""
).strip()


def create_parser():
parser = argparse.ArgumentParser(
prog="vcspull",
formatter_class=argparse.RawDescriptionHelpFormatter,
description=textwrap.dedent(
"""
sync vcspull repos

examples:
vcspull sync "*"
vcspull sync "django-*"
vcspull sync "django-*" flask
vcspull sync -c "myrepos.yaml" "*"
vcspull sync -c "myrepos.yaml" myproject
"""
).strip(),
description=SYNC_DESCRIPTION,
)
parser.add_argument(
"--version",
Expand All @@ -42,20 +44,26 @@ def create_parser():
)
parser.add_argument(
"--log-level",
metavar="level",
action="store",
default="INFO",
help="log level (DEBUG, INFO, WARNING, ERROR, CRITICAL)",
help="log level (debug, info, warning, error, critical)",
)

subparsers = parser.add_subparsers(dest="subparser_name")
sync_parser = subparsers.add_parser("sync", help="synchronize repos")
sync_parser = subparsers.add_parser(
"sync",
help="synchronize repos",
formatter_class=argparse.RawDescriptionHelpFormatter,
description=SYNC_DESCRIPTION,
)
create_sync_subparser(sync_parser)

return parser
return parser, sync_parser


def cli(args=None):
parser = create_parser()
parser, sync_parser = create_parser()
args = parser.parse_args(args)

setup_logger(log=log, level=args.log_level.upper())
Expand All @@ -68,5 +76,5 @@ def cli(args=None):
repo_terms=args.repo_terms,
config=args.config,
exit_on_error=args.exit_on_error,
parser=parser,
parser=sync_parser,
)
12 changes: 9 additions & 3 deletions src/vcspull/cli/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,24 @@ def clamp(n, _min, _max):


def create_sync_subparser(parser: argparse.ArgumentParser) -> argparse.ArgumentParser:
config_file = parser.add_argument("--config", "-c", help="specify config")
config_file = parser.add_argument(
"--config",
"-c",
metavar="config-file",
help="optional filepath to specify vcspull config",
)
parser.add_argument(
"repo_terms",
metavar="filter",
nargs="*",
help="filters: repo terms, separated by spaces, supports globs / fnmatch (1)",
help="patterns / terms of repos, accepts globs / fnmatch(3)",
)
parser.add_argument(
"--exit-on-error",
"-x",
action="store_true",
dest="exit_on_error",
help="exit immediately when encountering an error syncing multiple repos",
help="exit immediately encountering error (when syncing multiple repos)",
)

try:
Expand Down
6 changes: 3 additions & 3 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class SyncCLINonExistentRepo(t.NamedTuple):
SYNC_CLI_EXISTENT_REPO_FIXTURES,
ids=[test.test_id for test in SYNC_CLI_EXISTENT_REPO_FIXTURES],
)
def test_sync_cli_repo_term_non_existent(
def test_sync_cli_filter_non_existent(
tmp_path: pathlib.Path,
capsys: pytest.CaptureFixture,
monkeypatch: pytest.MonkeyPatch,
Expand Down Expand Up @@ -165,14 +165,14 @@ class SyncFixture(t.NamedTuple):
test_id="sync---help",
sync_args=["sync", "--help"],
expected_exit_code=0,
expected_in_out=["repo_terms", "--exit-on-error"],
expected_in_out=["filter", "--exit-on-error"],
expected_not_in_out="--version",
),
SyncFixture(
test_id="sync--h",
sync_args=["sync", "-h"],
expected_exit_code=0,
expected_in_out=["repo_terms", "--exit-on-error"],
expected_in_out=["filter", "--exit-on-error"],
expected_not_in_out="--version",
),
# Sync: Repo terms
Expand Down