From 13ca6c94c2f1016cde54d9c8b08cf5c2ec04d0e1 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: 2022年10月16日 14:43:21 -0500 Subject: [PATCH 1/6] 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 3e3fa389..2ddebb47 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 ffd42e2650fa5f09249b7db38edb36eba9b3942d Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: 2022年10月16日 14:49:53 -0500 Subject: [PATCH 2/6] refactor(cli[sync]): repo_term -> repo_patterns (metavar: filter) --- src/vcspull/cli/__init__.py | 2 +- src/vcspull/cli/sync.py | 19 ++++++++++--------- tests/test_cli.py | 10 ++++------ 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/vcspull/cli/__init__.py b/src/vcspull/cli/__init__.py index 5757043b..7b5f0834 100644 --- a/src/vcspull/cli/__init__.py +++ b/src/vcspull/cli/__init__.py @@ -48,7 +48,7 @@ def cli(args=None): return elif args.subparser_name == "sync": sync( - repo_terms=args.repo_terms, + repo_pattern=args.repo_pattern, config=args.config, exit_on_error=args.exit_on_error, parser=parser, diff --git a/src/vcspull/cli/sync.py b/src/vcspull/cli/sync.py index 2ddebb47..121c4748 100644 --- a/src/vcspull/cli/sync.py +++ b/src/vcspull/cli/sync.py @@ -23,9 +23,10 @@ def clamp(n, _min, _max): def create_sync_subparser(parser: argparse.ArgumentParser) -> argparse.ArgumentParser: config_file = parser.add_argument("--config", "-c", help="specify config") parser.add_argument( - "repo_terms", + "repo_pattern", + 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", @@ -44,7 +45,7 @@ def create_sync_subparser(parser: argparse.ArgumentParser) -> argparse.ArgumentP def sync( - repo_terms, + repo_pattern, config, exit_on_error: bool, parser: t.Optional[ @@ -57,14 +58,14 @@ def sync( configs = load_configs(find_config_files(include_home=True)) found_repos = [] - for repo_term in repo_terms: + for repo_pattern in repo_pattern: dir, vcs_url, name = None, None, None - if any(repo_term.startswith(n) for n in ["./", "/", "~", "$HOME"]): - dir = repo_term - elif any(repo_term.startswith(n) for n in ["http", "git", "svn", "hg"]): - vcs_url = repo_term + if any(repo_pattern.startswith(n) for n in ["./", "/", "~", "$HOME"]): + dir = repo_pattern + elif any(repo_pattern.startswith(n) for n in ["http", "git", "svn", "hg"]): + vcs_url = repo_pattern else: - name = repo_term + name = repo_pattern # collect the repos from the config files found = filter_repos(configs, dir=dir, vcs_url=vcs_url, name=name) diff --git a/tests/test_cli.py b/tests/test_cli.py index 0fee8b09..3a49094b 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, @@ -158,9 +158,7 @@ class SyncFixture(t.NamedTuple): test_id="sync--empty", sync_args=["sync"], expected_exit_code=1, - expected_in_out=( - "sync: error: the following arguments are required: repo_terms" - ), + expected_in_out=("sync: error: the following arguments are required: filter"), expected_not_in_out="positional arguments:", ), # Sync: Help @@ -168,14 +166,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 8e70af031f1744a4cc1cd4738d528f4a5650155f Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: 2022年10月16日 14:52:28 -0500 Subject: [PATCH 3/6] 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 121c4748..2eeb50eb 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_pattern", metavar="filter", From 8a5d73afeb9c56667645ab21dcc6d6ea0611e268 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: 2022年10月16日 14:53:40 -0500 Subject: [PATCH 4/6] 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 2eeb50eb..a42c6913 100644 --- a/src/vcspull/cli/sync.py +++ b/src/vcspull/cli/sync.py @@ -38,7 +38,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: import shtab From 1fe36d083db9bc15609cd29a600b356bd4c13ffe Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: 2022年10月16日 14:54:21 -0500 Subject: [PATCH 5/6] docs(CHANGES): Note CLI copy updates --- CHANGES | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES b/CHANGES index aaefc63e..36869894 100644 --- a/CHANGES +++ b/CHANGES @@ -21,6 +21,10 @@ $ pipx install --suffix=@next 'vcspull' --pip-args '\--pre' --force +### CLI + +- Copy updates and metavar updates for `vcspull sync` (#404) + ## vcspull v1.15.4 (2022年10月16日) ### CLI From 6d852798ceb885c77641fee65daebbe9d75b4a34 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: 2022年10月16日 15:06:59 -0500 Subject: [PATCH 6/6] Revert "CLI: Naming cleanup" --- CHANGES | 4 ---- src/vcspull/cli/__init__.py | 2 +- src/vcspull/cli/sync.py | 28 +++++++++++----------------- tests/test_cli.py | 10 ++++++---- 4 files changed, 18 insertions(+), 26 deletions(-) diff --git a/CHANGES b/CHANGES index 36869894..aaefc63e 100644 --- a/CHANGES +++ b/CHANGES @@ -21,10 +21,6 @@ $ pipx install --suffix=@next 'vcspull' --pip-args '\--pre' --force -### CLI - -- Copy updates and metavar updates for `vcspull sync` (#404) - ## vcspull v1.15.4 (2022年10月16日) ### CLI diff --git a/src/vcspull/cli/__init__.py b/src/vcspull/cli/__init__.py index 7b5f0834..5757043b 100644 --- a/src/vcspull/cli/__init__.py +++ b/src/vcspull/cli/__init__.py @@ -48,7 +48,7 @@ def cli(args=None): return elif args.subparser_name == "sync": sync( - repo_pattern=args.repo_pattern, + repo_terms=args.repo_terms, config=args.config, exit_on_error=args.exit_on_error, parser=parser, diff --git a/src/vcspull/cli/sync.py b/src/vcspull/cli/sync.py index a42c6913..3e3fa389 100644 --- a/src/vcspull/cli/sync.py +++ b/src/vcspull/cli/sync.py @@ -21,24 +21,18 @@ def clamp(n, _min, _max): def create_sync_subparser(parser: argparse.ArgumentParser) -> argparse.ArgumentParser: - config_file = parser.add_argument( - "--config", - "-c", - metavar="config-file", - help="optional filepath to specify vcspull config", - ) + config_file = parser.add_argument("--config", "-c", help="specify config") parser.add_argument( - "repo_pattern", - metavar="filter", + "repo_terms", nargs="+", - help="patterns / terms of repos, accepts globs / fnmatch(3)", + help="filters: repo terms, separated by spaces, supports globs / fnmatch (1)", ) parser.add_argument( "--exit-on-error", "-x", action="store_true", dest="exit_on_error", - help="exit immediately encountering error (when syncing multiple repos)", + help="exit immediately when encountering an error syncing multiple repos", ) try: import shtab @@ -50,7 +44,7 @@ def create_sync_subparser(parser: argparse.ArgumentParser) -> argparse.ArgumentP def sync( - repo_pattern, + repo_terms, config, exit_on_error: bool, parser: t.Optional[ @@ -63,14 +57,14 @@ def sync( configs = load_configs(find_config_files(include_home=True)) found_repos = [] - for repo_pattern in repo_pattern: + for repo_term in repo_terms: dir, vcs_url, name = None, None, None - if any(repo_pattern.startswith(n) for n in ["./", "/", "~", "$HOME"]): - dir = repo_pattern - elif any(repo_pattern.startswith(n) for n in ["http", "git", "svn", "hg"]): - vcs_url = repo_pattern + if any(repo_term.startswith(n) for n in ["./", "/", "~", "$HOME"]): + dir = repo_term + elif any(repo_term.startswith(n) for n in ["http", "git", "svn", "hg"]): + vcs_url = repo_term else: - name = repo_pattern + name = repo_term # collect the repos from the config files found = filter_repos(configs, dir=dir, vcs_url=vcs_url, name=name) diff --git a/tests/test_cli.py b/tests/test_cli.py index 3a49094b..0fee8b09 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_filter_non_existent( +def test_sync_cli_repo_term_non_existent( tmp_path: pathlib.Path, capsys: pytest.CaptureFixture, monkeypatch: pytest.MonkeyPatch, @@ -158,7 +158,9 @@ class SyncFixture(t.NamedTuple): test_id="sync--empty", sync_args=["sync"], expected_exit_code=1, - expected_in_out=("sync: error: the following arguments are required: filter"), + expected_in_out=( + "sync: error: the following arguments are required: repo_terms" + ), expected_not_in_out="positional arguments:", ), # Sync: Help @@ -166,14 +168,14 @@ class SyncFixture(t.NamedTuple): test_id="sync---help", sync_args=["sync", "--help"], expected_exit_code=0, - expected_in_out=["filter", "--exit-on-error"], + expected_in_out=["repo_terms", "--exit-on-error"], expected_not_in_out="--version", ), SyncFixture( test_id="sync--h", sync_args=["sync", "-h"], expected_exit_code=0, - expected_in_out=["filter", "--exit-on-error"], + expected_in_out=["repo_terms", "--exit-on-error"], expected_not_in_out="--version", ), # Sync: Repo terms

AltStyle によって変換されたページ (->オリジナル) /