diff --git a/CHANGES b/CHANGES index 680b99ea..c75b63cf 100644 --- a/CHANGES +++ b/CHANGES @@ -21,6 +21,12 @@ $ pipx install --suffix=@next 'vcspull' --pip-args '\--pre' --force +## vcspull v1.15.7 (unreleased) + +### CLI + +- `vcspull` and `vcspull sync` Copy updates and metavar updates (#404) + ## vcspull v1.15.6 (2022-10-16) ### CLI diff --git a/src/vcspull/cli/__init__.py b/src/vcspull/cli/__init__.py index d87136f7..d1d95f53 100644 --- a/src/vcspull/cli/__init__.py +++ b/src/vcspull/cli/__init__.py @@ -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", @@ -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()) @@ -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, ) diff --git a/src/vcspull/cli/sync.py b/src/vcspull/cli/sync.py index cfab2464..a3a2e704 100644 --- a/src/vcspull/cli/sync.py +++ b/src/vcspull/cli/sync.py @@ -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: diff --git a/tests/test_cli.py b/tests/test_cli.py index 9edb55e1..586f71ff 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -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, @@ -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