Skip to content

Commit db913f7

Browse files
committed
feat(cli/import[style]) Use central format_repo_entry with --style
why: Replace hardcoded {"repo": url} in the import pipeline with the central formatting API so all six service handlers respect --style. what: - Add --style to _create_shared_parent() output group - Replace dict literal in _run_import() with format_repo_entry() - Pass style from each service handler to _run_import()
1 parent 678a3aa commit db913f7

7 files changed

Lines changed: 20 additions & 3 deletions

File tree

src/vcspull/cli/import_cmd/_common.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import typing as t
1414

1515
from vcspull._internal.config_reader import ConfigReader
16+
from vcspull._internal.config_style import format_repo_entry
1617
from vcspull._internal.private_path import PrivatePath
1718
from vcspull._internal.remotes import (
1819
AuthenticationError,
@@ -25,6 +26,7 @@
2526
RemoteRepo,
2627
ServiceUnavailableError,
2728
)
29+
from vcspull._internal.settings import resolve_style
2830
from vcspull.config import (
2931
find_home_config_files,
3032
save_config_json,
@@ -162,6 +164,13 @@ def _create_shared_parent() -> argparse.ArgumentParser:
162164
default="auto",
163165
help="When to use colors (default: auto)",
164166
)
167+
output_group.add_argument(
168+
"--style",
169+
dest="style",
170+
choices=["concise", "standard", "verbose"],
171+
default=None,
172+
help="Config entry style (concise, standard, verbose)",
173+
)
165174
return parent
166175

167176

@@ -281,6 +290,7 @@ def _run_import(
281290
color: str,
282291
use_https: bool = False,
283292
flatten_groups: bool = False,
293+
style: str | None = None,
284294
) -> int:
285295
"""Run the import workflow for a single service.
286296
@@ -603,9 +613,10 @@ def _run_import(
603613
skipped_count += 1
604614
continue
605615

606-
raw_config[repo_workspace_label][repo.name] = {
607-
"repo": repo.to_vcspull_url(use_ssh=not use_https),
608-
}
616+
resolved_style = resolve_style(style)
617+
raw_config[repo_workspace_label][repo.name] = format_repo_entry(
618+
repo.to_vcspull_url(use_ssh=not use_https), style=resolved_style
619+
)
609620
added_count += 1
610621

611622
if error_labels:

src/vcspull/cli/import_cmd/codeberg.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,5 @@ def handle_codeberg(args: argparse.Namespace) -> int:
8181
output_ndjson=getattr(args, "output_ndjson", False),
8282
color=getattr(args, "color", "auto"),
8383
use_https=getattr(args, "use_https", False),
84+
style=getattr(args, "style", None),
8485
)

src/vcspull/cli/import_cmd/codecommit.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,5 @@ def handle_codecommit(args: argparse.Namespace) -> int:
101101
output_ndjson=getattr(args, "output_ndjson", False),
102102
color=getattr(args, "color", "auto"),
103103
use_https=getattr(args, "use_https", False),
104+
style=getattr(args, "style", None),
104105
)

src/vcspull/cli/import_cmd/forgejo.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,5 @@ def handle_forgejo(args: argparse.Namespace) -> int:
8888
output_ndjson=getattr(args, "output_ndjson", False),
8989
color=getattr(args, "color", "auto"),
9090
use_https=getattr(args, "use_https", False),
91+
style=getattr(args, "style", None),
9192
)

src/vcspull/cli/import_cmd/gitea.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,5 @@ def handle_gitea(args: argparse.Namespace) -> int:
8888
output_ndjson=getattr(args, "output_ndjson", False),
8989
color=getattr(args, "color", "auto"),
9090
use_https=getattr(args, "use_https", False),
91+
style=getattr(args, "style", None),
9192
)

src/vcspull/cli/import_cmd/github.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,5 @@ def handle_github(args: argparse.Namespace) -> int:
9090
output_ndjson=getattr(args, "output_ndjson", False),
9191
color=getattr(args, "color", "auto"),
9292
use_https=getattr(args, "use_https", False),
93+
style=getattr(args, "style", None),
9394
)

src/vcspull/cli/import_cmd/gitlab.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,5 @@ def handle_gitlab(args: argparse.Namespace) -> int:
9898
color=getattr(args, "color", "auto"),
9999
use_https=getattr(args, "use_https", False),
100100
flatten_groups=getattr(args, "flatten_groups", False),
101+
style=getattr(args, "style", None),
101102
)

0 commit comments

Comments
 (0)