Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ffd42e2

Browse filesBrowse files
committed
refactor(cli[sync]): repo_term -> repo_patterns (metavar: filter)
1 parent 13ca6c9 commit ffd42e2
Copy full SHA for ffd42e2

File tree

Expand file treeCollapse file tree

3 files changed

+15
-16
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+15
-16
lines changed

‎src/vcspull/cli/__init__.py

Copy file name to clipboardExpand all lines: src/vcspull/cli/__init__.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def cli(args=None):
4848
return
4949
elif args.subparser_name == "sync":
5050
sync(
51-
repo_terms=args.repo_terms,
51+
repo_pattern=args.repo_pattern,
5252
config=args.config,
5353
exit_on_error=args.exit_on_error,
5454
parser=parser,

‎src/vcspull/cli/sync.py

Copy file name to clipboardExpand all lines: src/vcspull/cli/sync.py
+10-9Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ def clamp(n, _min, _max):
2323
def create_sync_subparser(parser: argparse.ArgumentParser) -> argparse.ArgumentParser:
2424
config_file = parser.add_argument("--config", "-c", help="specify config")
2525
parser.add_argument(
26-
"repo_terms",
26+
"repo_pattern",
27+
metavar="filter",
2728
nargs="+",
28-
help="filter(s) of repo terms, separated by spaces, accepts globs / fnmatch(3)",
29+
help="patterns / terms of repos, accepts globs / fnmatch(3)",
2930
)
3031
parser.add_argument(
3132
"--exit-on-error",
@@ -44,7 +45,7 @@ def create_sync_subparser(parser: argparse.ArgumentParser) -> argparse.ArgumentP
4445

4546

4647
def sync(
47-
repo_terms,
48+
repo_pattern,
4849
config,
4950
exit_on_error: bool,
5051
parser: t.Optional[
@@ -57,14 +58,14 @@ def sync(
5758
configs = load_configs(find_config_files(include_home=True))
5859
found_repos = []
5960

60-
for repo_term in repo_terms:
61+
for repo_pattern in repo_pattern:
6162
dir, vcs_url, name = None, None, None
62-
if any(repo_term.startswith(n) for n in ["./", "/", "~", "$HOME"]):
63-
dir = repo_term
64-
elif any(repo_term.startswith(n) for n in ["http", "git", "svn", "hg"]):
65-
vcs_url = repo_term
63+
if any(repo_pattern.startswith(n) for n in ["./", "/", "~", "$HOME"]):
64+
dir = repo_pattern
65+
elif any(repo_pattern.startswith(n) for n in ["http", "git", "svn", "hg"]):
66+
vcs_url = repo_pattern
6667
else:
67-
name = repo_term
68+
name = repo_pattern
6869

6970
# collect the repos from the config files
7071
found = filter_repos(configs, dir=dir, vcs_url=vcs_url, name=name)

‎tests/test_cli.py

Copy file name to clipboardExpand all lines: tests/test_cli.py
+4-6Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class SyncCLINonExistentRepo(t.NamedTuple):
5959
SYNC_CLI_EXISTENT_REPO_FIXTURES,
6060
ids=[test.test_id for test in SYNC_CLI_EXISTENT_REPO_FIXTURES],
6161
)
62-
def test_sync_cli_repo_term_non_existent(
62+
def test_sync_cli_filter_non_existent(
6363
tmp_path: pathlib.Path,
6464
capsys: pytest.CaptureFixture,
6565
monkeypatch: pytest.MonkeyPatch,
@@ -158,24 +158,22 @@ class SyncFixture(t.NamedTuple):
158158
test_id="sync--empty",
159159
sync_args=["sync"],
160160
expected_exit_code=1,
161-
expected_in_out=(
162-
"sync: error: the following arguments are required: repo_terms"
163-
),
161+
expected_in_out=("sync: error: the following arguments are required: filter"),
164162
expected_not_in_out="positional arguments:",
165163
),
166164
# Sync: Help
167165
SyncFixture(
168166
test_id="sync---help",
169167
sync_args=["sync", "--help"],
170168
expected_exit_code=0,
171-
expected_in_out=["repo_terms", "--exit-on-error"],
169+
expected_in_out=["filter", "--exit-on-error"],
172170
expected_not_in_out="--version",
173171
),
174172
SyncFixture(
175173
test_id="sync--h",
176174
sync_args=["sync", "-h"],
177175
expected_exit_code=0,
178-
expected_in_out=["repo_terms", "--exit-on-error"],
176+
expected_in_out=["filter", "--exit-on-error"],
179177
expected_not_in_out="--version",
180178
),
181179
# Sync: Repo terms

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.