Skip to content

Commit b58ce09

Browse files
committed
Add interactive mode to concore init CLI
1 parent b44e9a1 commit b58ce09

2 files changed

Lines changed: 18 additions & 16 deletions

File tree

concore_cli/cli.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ def cli():
2727
@click.argument("name", required=False, default=None)
2828
@click.option("--template", default="basic", help="Template type to use")
2929
@click.option(
30-
"--interactive", "-i",
30+
"--interactive",
31+
"-i",
3132
is_flag=True,
3233
help="Launch guided wizard to select node types",
3334
)
@@ -44,7 +45,9 @@ def init(name, template, interactive):
4445
init_project_interactive(name, selected, console)
4546
else:
4647
if not name:
47-
console.print("[red]Error:[/red] Provide a project name or use --interactive.")
48+
console.print(
49+
"[red]Error:[/red] Provide a project name or use --interactive."
50+
)
4851
sys.exit(1)
4952
init_project(name, template, console)
5053
except Exception as e:

concore_cli/commands/init.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133
" concore.simtime = 0;\n"
134134
" // set your maxtime (or let concore.maxtime file override)\n\n"
135135
" while (concore.simtime < 100) begin\n"
136-
' while (concore.unchanged(0)) begin\n'
136+
" while (concore.unchanged(0)) begin\n"
137137
" // readdata fills concore.data[] and updates concore.simtime\n"
138138
' concore.readdata(1, "data", "[0.0,0.0]");\n'
139139
" end\n"
@@ -203,6 +203,7 @@
203203
# Interactive wizard
204204
# ---------------------------------------------------------------------------
205205

206+
206207
def run_wizard(console):
207208
"""Ask y/n for each supported language. Returns list of selected lang keys."""
208209
console.print()
@@ -214,9 +215,11 @@ def run_wizard(console):
214215

215216
selected = []
216217
for key, info in LANGUAGE_NODES.items():
217-
raw = console.input(
218-
f" Include [bold]{info['label']}[/bold] node? [Y/n] "
219-
).strip().lower()
218+
raw = (
219+
console.input(f" Include [bold]{info['label']}[/bold] node? [Y/n] ")
220+
.strip()
221+
.lower()
222+
)
220223
if raw in ("", "y", "yes"):
221224
selected.append(key)
222225

@@ -227,6 +230,7 @@ def run_wizard(console):
227230
# GraphML builder
228231
# ---------------------------------------------------------------------------
229232

233+
230234
def _build_graphml(project_name, selected_langs):
231235
"""Return a GraphML string with one unconnected node per selected language."""
232236
node_blocks = []
@@ -235,7 +239,7 @@ def _build_graphml(project_name, selected_langs):
235239
node_blocks.append(
236240
GRAPHML_NODE.format(
237241
idx=idx,
238-
y=100 + (idx - 1) * 100, # stack vertically, 100 px apart
242+
y=100 + (idx - 1) * 100, # stack vertically, 100 px apart
239243
color=info["color"],
240244
filename=info["filename"],
241245
)
@@ -250,6 +254,7 @@ def _build_graphml(project_name, selected_langs):
250254
# Public entry points
251255
# ---------------------------------------------------------------------------
252256

257+
253258
def init_project_interactive(name, selected_langs, console):
254259
"""Create a project with one node per selected language (no edges)."""
255260
project_path = Path(name)
@@ -278,9 +283,7 @@ def init_project_interactive(name, selected_langs, console):
278283
(src_path / info["filename"]).write_text(info["stub"])
279284

280285
# README
281-
(project_path / "README.md").write_text(
282-
README_TEMPLATE.format(project_name=name)
283-
)
286+
(project_path / "README.md").write_text(README_TEMPLATE.format(project_name=name))
284287

285288
# Metadata
286289
metadata_info = ""
@@ -333,13 +336,9 @@ def init_project(name, template, console):
333336
with open(workflow_file, "w") as f:
334337
f.write(SAMPLE_GRAPHML)
335338

336-
(project_path / "src" / "script.py").write_text(
337-
LANGUAGE_NODES["python"]["stub"]
338-
)
339+
(project_path / "src" / "script.py").write_text(LANGUAGE_NODES["python"]["stub"])
339340

340-
(project_path / "README.md").write_text(
341-
README_TEMPLATE.format(project_name=name)
342-
)
341+
(project_path / "README.md").write_text(README_TEMPLATE.format(project_name=name))
343342

344343
metadata_info = ""
345344
try:

0 commit comments

Comments
 (0)