Skip to content

Commit 8046353

Browse files
committed
cli/add(refactor): Make repository path the sole positional
why: CLI accepted name+URL combinations that bypassed the path-first flow, leaving repos under './' and skipping confirmations. what: - replace the positional name/url pair with a single repo_path argument plus optional --url/--name overrides - default workspace detection to the directory parent and contract saved config paths with contract_user_home
1 parent 21672a2 commit 8046353

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

src/vcspull/cli/add.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,22 @@ def create_add_subparser(parser: argparse.ArgumentParser) -> None:
3737
The parser to configure
3838
"""
3939
parser.add_argument(
40-
"target",
40+
"repo_path",
4141
help=(
42-
"Repository name (when providing a URL) or filesystem path to an "
43-
"existing project"
42+
"Filesystem path to an existing project. The parent directory "
43+
"becomes the workspace unless overridden with --workspace."
4444
),
4545
)
46-
parser.add_argument(
47-
"url",
48-
nargs="?",
49-
help="Repository URL when explicitly specifying the name",
50-
)
5146
parser.add_argument(
5247
"--name",
5348
dest="override_name",
5449
help="Override detected repository name when importing from a path",
5550
)
51+
parser.add_argument(
52+
"--url",
53+
dest="url",
54+
help="Repository URL to record (overrides detected remotes)",
55+
)
5656
parser.add_argument(
5757
"-f",
5858
"--file",
@@ -67,8 +67,8 @@ def create_add_subparser(parser: argparse.ArgumentParser) -> None:
6767
dest="workspace_root_path",
6868
metavar="DIR",
6969
help=(
70-
"Workspace root directory in config (e.g., '~/projects/'). "
71-
"If not specified, will be inferred from --path or use current directory."
70+
"Workspace root directory in config (e.g., '~/projects/'). Defaults "
71+
"to the parent directory of the repository path."
7272
),
7373
)
7474
parser.add_argument(
@@ -322,7 +322,7 @@ def add_repo(
322322
config_file_path = pathlib.Path.cwd() / ".vcspull.yaml"
323323
log.info(
324324
"No config specified and no default found, will create at %s",
325-
config_file_path,
325+
contract_user_home(config_file_path),
326326
)
327327
elif len(home_configs) > 1:
328328
log.error(
@@ -335,6 +335,8 @@ def add_repo(
335335
# Load existing config
336336
raw_config: dict[str, t.Any]
337337
duplicate_root_occurrences: dict[str, list[t.Any]]
338+
display_config_path = contract_user_home(config_file_path)
339+
338340
if config_file_path.exists() and config_file_path.is_file():
339341
try:
340342
(
@@ -494,7 +496,7 @@ def add_repo(
494496
Fore.YELLOW,
495497
Style.RESET_ALL,
496498
Fore.BLUE,
497-
config_file_path,
499+
display_config_path,
498500
Style.RESET_ALL,
499501
)
500502
else:
@@ -505,7 +507,7 @@ def add_repo(
505507
Fore.GREEN,
506508
Style.RESET_ALL,
507509
Fore.BLUE,
508-
config_file_path,
510+
display_config_path,
509511
Style.RESET_ALL,
510512
)
511513
except Exception:
@@ -530,7 +532,7 @@ def add_repo(
530532
url,
531533
Style.RESET_ALL,
532534
Fore.BLUE,
533-
config_file_path,
535+
display_config_path,
534536
Style.RESET_ALL,
535537
Fore.MAGENTA,
536538
workspace_label,
@@ -550,7 +552,7 @@ def add_repo(
550552
url,
551553
Style.RESET_ALL,
552554
Fore.BLUE,
553-
config_file_path,
555+
display_config_path,
554556
Style.RESET_ALL,
555557
Fore.MAGENTA,
556558
workspace_label,

0 commit comments

Comments
 (0)