Skip to content

Commit c6e23d9

Browse files
committed
feat(cli/add[style]) Use central format_repo_entry with --style
why: Replace hardcoded {"repo": url} with the central formatting API so add respects the user's style preference. what: - Add --style arg to create_add_subparser() - Replace new_repo_entry = {"repo": url} with format_repo_entry() - Pass style from handle_add_command → add_repo via resolve_style()
1 parent 126631e commit c6e23d9

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

src/vcspull/cli/add.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
from colorama import Fore, Style
1414

1515
from vcspull._internal.config_reader import DuplicateAwareConfigReader
16+
from vcspull._internal.config_style import format_repo_entry
1617
from vcspull._internal.private_path import PrivatePath
18+
from vcspull._internal.settings import resolve_style
1719
from vcspull.config import (
1820
canonicalize_workspace_path,
1921
expand_dir,
@@ -91,6 +93,13 @@ def create_add_subparser(parser: argparse.ArgumentParser) -> None:
9193
action="store_true",
9294
help="Automatically confirm interactive prompts",
9395
)
96+
parser.add_argument(
97+
"--style",
98+
dest="style",
99+
choices=["concise", "standard", "verbose"],
100+
default=None,
101+
help="Config entry style (concise, standard, verbose)",
102+
)
94103
parser.set_defaults(merge_duplicates=True)
95104

96105

@@ -334,6 +343,7 @@ def handle_add_command(args: argparse.Namespace) -> None:
334343
workspace_root_path=workspace_root_input,
335344
dry_run=args.dry_run,
336345
merge_duplicates=args.merge_duplicates,
346+
style=getattr(args, "style", None),
337347
)
338348

339349

@@ -346,6 +356,7 @@ def add_repo(
346356
dry_run: bool,
347357
*,
348358
merge_duplicates: bool = True,
359+
style: str | None = None,
349360
) -> None:
350361
"""Add a repository to the vcspull configuration.
351362
@@ -363,6 +374,8 @@ def add_repo(
363374
Workspace root to use in config
364375
dry_run : bool
365376
If True, preview changes without writing
377+
style : str | None
378+
Config entry style (concise, standard, verbose).
366379
"""
367380
# Determine config file
368381
config_file_path: pathlib.Path
@@ -438,7 +451,11 @@ def add_repo(
438451
preserve_cwd_label=explicit_dot,
439452
)
440453

441-
new_repo_entry = {"repo": url}
454+
resolved_style = resolve_style(style)
455+
repo_path_obj = pathlib.Path(path) if path else None
456+
new_repo_entry = format_repo_entry(
457+
url, style=resolved_style, repo_path=repo_path_obj
458+
)
442459

443460
def _ensure_workspace_label_for_merge(
444461
config_data: dict[str, t.Any],

0 commit comments

Comments
 (0)