Skip to content

Commit c24f08a

Browse files
committed
feat(cli): add example to _ask_name choice
1 parent 5857050 commit c24f08a

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

commitizen/commands/init.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,20 @@ def _ask_config_path(self) -> Path:
165165
return Path(filename)
166166

167167
def _ask_name(self) -> str:
168+
169+
def construct_choice_with_example(cz_name: str) -> questionary.Choice:
170+
cz_class = registry.get(cz_name)
171+
if cz_class:
172+
first_example = cz_class.example().splitlines()[0]
173+
title = f"{cz_name}: {first_example}"
174+
return questionary.Choice(title=title, value=cz_name)
175+
return questionary.Choice(title=cz_name, value=cz_name)
176+
168177
name: str = questionary.select(
169178
"Please choose a cz (commit rule): (default: cz_conventional_commits)",
170-
choices=list(registry.keys()),
179+
choices=[
180+
construct_choice_with_example(cz_name) for cz_name in registry.keys()
181+
],
171182
default="cz_conventional_commits",
172183
style=self.cz.style,
173184
).unsafe_ask()

0 commit comments

Comments
 (0)