From 24b9589f6e88c93758132170f8ead09219cc492b Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sun, 16 Oct 2022 14:43:21 -0500 Subject: [PATCH 1/8] chore(cli[sync]): Improve repo_terms copy --- src/vcspull/cli/sync.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vcspull/cli/sync.py b/src/vcspull/cli/sync.py index cfab2464..b9d114c8 100644 --- a/src/vcspull/cli/sync.py +++ b/src/vcspull/cli/sync.py @@ -25,7 +25,7 @@ def create_sync_subparser(parser: argparse.ArgumentParser) -> argparse.ArgumentP parser.add_argument( "repo_terms", nargs="*", - help="filters: repo terms, separated by spaces, supports globs / fnmatch (1)", + help="filter(s) of repo terms, separated by spaces, accepts globs / fnmatch(3)", ) parser.add_argument( "--exit-on-error", From e289ffec1631f8029d1a6122a9309a8927ed032c Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sun, 16 Oct 2022 14:52:28 -0500 Subject: [PATCH 2/8] chore(cli[sync]): metavar for vcspull sync config --- src/vcspull/cli/sync.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/vcspull/cli/sync.py b/src/vcspull/cli/sync.py index b9d114c8..b7600ff8 100644 --- a/src/vcspull/cli/sync.py +++ b/src/vcspull/cli/sync.py @@ -21,7 +21,12 @@ 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", nargs="*", From ed3cbbbb2cc7211f113ccae668c148aa3b84dc8f Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sun, 16 Oct 2022 14:53:40 -0500 Subject: [PATCH 3/8] chore(cli[sync]): Update exit-on-error copy --- src/vcspull/cli/sync.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vcspull/cli/sync.py b/src/vcspull/cli/sync.py index b7600ff8..46977969 100644 --- a/src/vcspull/cli/sync.py +++ b/src/vcspull/cli/sync.py @@ -37,7 +37,7 @@ def create_sync_subparser(parser: argparse.ArgumentParser) -> argparse.ArgumentP "-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: From 1c744075eb7886080c09e196566c207e13f011f5 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sun, 16 Oct 2022 17:26:49 -0500 Subject: [PATCH 4/8] chore(cli): Copy tweaks --- src/vcspull/cli/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/vcspull/cli/__init__.py b/src/vcspull/cli/__init__.py index d87136f7..51e7e3b4 100644 --- a/src/vcspull/cli/__init__.py +++ b/src/vcspull/cli/__init__.py @@ -23,14 +23,14 @@ def create_parser(): formatter_class=argparse.RawDescriptionHelpFormatter, description=textwrap.dedent( """ - sync vcspull repos + sync vcs repos examples: vcspull sync "*" vcspull sync "django-*" vcspull sync "django-*" flask - vcspull sync -c "myrepos.yaml" "*" - vcspull sync -c "myrepos.yaml" myproject + vcspull sync -c ./myrepos.yaml "*" + vcspull sync -c ./myrepos.yaml myproject """ ).strip(), ) From eee20e09ad173173d59d462a92d7371ba983bd91 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sun, 16 Oct 2022 17:32:31 -0500 Subject: [PATCH 5/8] chore(cli): Log level help text, metavar --- src/vcspull/cli/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/vcspull/cli/__init__.py b/src/vcspull/cli/__init__.py index 51e7e3b4..152fb167 100644 --- a/src/vcspull/cli/__init__.py +++ b/src/vcspull/cli/__init__.py @@ -42,9 +42,10 @@ 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") From 7792eaec962c6ae5fd3246a1b0df3a3c6f2d9d16 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sun, 16 Oct 2022 17:44:26 -0500 Subject: [PATCH 6/8] chore(cli[sync]): metavar and help text --- src/vcspull/cli/sync.py | 3 ++- tests/test_cli.py | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/vcspull/cli/sync.py b/src/vcspull/cli/sync.py index 46977969..a3a2e704 100644 --- a/src/vcspull/cli/sync.py +++ b/src/vcspull/cli/sync.py @@ -29,8 +29,9 @@ def create_sync_subparser(parser: argparse.ArgumentParser) -> argparse.ArgumentP ) parser.add_argument( "repo_terms", + metavar="filter", nargs="*", - help="filter(s) of repo terms, separated by spaces, accepts globs / fnmatch(3)", + help="patterns / terms of repos, accepts globs / fnmatch(3)", ) parser.add_argument( "--exit-on-error", 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 From b5e489689a313c8b5d009e9430652e9879f10a34 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sun, 16 Oct 2022 17:56:42 -0500 Subject: [PATCH 7/8] fix(cli): Show subparser-specific help text --- src/vcspull/cli/__init__.py | 39 ++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/src/vcspull/cli/__init__.py b/src/vcspull/cli/__init__.py index 152fb167..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 vcs 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", @@ -49,14 +51,19 @@ def create_parser(): ) 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()) @@ -69,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, ) From 7fac05767c763ae078d358cef38c184110d1ff15 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sun, 16 Oct 2022 14:54:21 -0500 Subject: [PATCH 8/8] docs(CHANGES): Note CLI copy updates --- CHANGES | 6 ++++++ 1 file changed, 6 insertions(+) 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