Skip to content

Commit 36824e1

Browse files
committed
feat(cli/discover[style]) Use central format_repo_entry with --style
why: Replace hardcoded {"repo": repo_url} with the central formatting API so discover respects the user's style preference. what: - Add --style arg to create_discover_subparser() - Replace {"repo": repo_url} with format_repo_entry() in discover loop - Pass style through cli/__init__.py dispatch to discover_repos() - Pass style through cli/__init__.py dispatch to format_config_file()
1 parent c6e23d9 commit 36824e1

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

src/vcspull/cli/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,13 +492,19 @@ def cli(_args: list[str] | None = None) -> None:
492492
yes=args.yes,
493493
dry_run=args.dry_run,
494494
merge_duplicates=args.merge_duplicates,
495+
style=getattr(args, "style", None),
495496
)
496497
elif args.subparser_name == "fmt":
498+
from vcspull._internal.settings import resolve_style
499+
500+
fmt_style = getattr(args, "style", None)
501+
resolved_fmt_style = resolve_style(fmt_style) if fmt_style is not None else None
497502
format_config_file(
498503
args.config,
499504
args.write,
500505
args.all,
501506
merge_roots=args.merge_roots,
507+
style=resolved_fmt_style,
502508
)
503509
elif args.subparser_name == "import":
504510
handler = getattr(args, "import_handler", None)

src/vcspull/cli/discover.py

Lines changed: 16 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,
@@ -171,6 +173,13 @@ def create_discover_subparser(parser: argparse.ArgumentParser) -> None:
171173
action="store_false",
172174
help="Skip merging duplicate workspace roots before writing",
173175
)
176+
parser.add_argument(
177+
"--style",
178+
dest="style",
179+
choices=["concise", "standard", "verbose"],
180+
default=None,
181+
help="Config entry style (concise, standard, verbose)",
182+
)
174183
parser.set_defaults(merge_duplicates=True)
175184

176185

@@ -212,6 +221,7 @@ def discover_repos(
212221
dry_run: bool,
213222
*,
214223
merge_duplicates: bool = True,
224+
style: str | None = None,
215225
) -> None:
216226
"""Scan filesystem for git repositories and add to vcspull config.
217227
@@ -229,6 +239,8 @@ def discover_repos(
229239
Whether to skip confirmation prompt
230240
dry_run : bool
231241
If True, preview changes without writing
242+
style : str | None
243+
Config entry style (concise, standard, verbose).
232244
"""
233245
scan_dir = expand_dir(pathlib.Path(scan_dir_str))
234246

@@ -609,7 +621,10 @@ def discover_repos(
609621
continue
610622

611623
if repo_name not in raw_config[workspace_label]:
612-
raw_config[workspace_label][repo_name] = {"repo": repo_url}
624+
resolved_style = resolve_style(style)
625+
raw_config[workspace_label][repo_name] = format_repo_entry(
626+
repo_url, style=resolved_style
627+
)
613628
log.info(
614629
"%s+%s Importing %s'%s'%s (%s%s%s) under '%s%s%s'.",
615630
Fore.GREEN,

0 commit comments

Comments
 (0)