Skip to content

Commit 1681f62

Browse files
committed
vibe it baby
1 parent b97bfa1 commit 1681f62

File tree

16 files changed

+3019
-209
lines changed

16 files changed

+3019
-209
lines changed

examples/cli_back_demo.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/usr/bin/env python
2+
"""
3+
Demonstration of the 'back' functionality in Data Designer CLI.
4+
5+
This example shows how to use the BACK sentinel value to implement
6+
navigation between prompts in a wizard-style interface.
7+
"""
8+
9+
from data_designer.cli.interactive import BACK, prompt_text_input, select_with_arrows
10+
11+
12+
def simple_wizard_with_back() -> None:
13+
"""Demonstrate a simple wizard that supports going back."""
14+
print("=== Simple Wizard with Back Support ===\n")
15+
16+
# Step 1: Get name
17+
step = 1
18+
name = None
19+
age = None
20+
color = None
21+
22+
while True:
23+
if step == 1:
24+
# First prompt - no back option
25+
name = prompt_text_input("What is your name?", default="Alice", allow_back=False)
26+
if name is None: # Cancelled
27+
print("Wizard cancelled!")
28+
return
29+
step = 2
30+
31+
elif step == 2:
32+
# Second prompt - can go back to step 1
33+
age = prompt_text_input("What is your age?", default="25", allow_back=True)
34+
if age is None: # Cancelled
35+
print("Wizard cancelled!")
36+
return
37+
elif age is BACK: # Go back
38+
step = 1
39+
continue
40+
step = 3
41+
42+
elif step == 3:
43+
# Third prompt - can go back to step 2
44+
color_options = {
45+
"red": "Red - Bold and vibrant",
46+
"blue": "Blue - Calm and serene",
47+
"green": "Green - Fresh and natural",
48+
}
49+
color = select_with_arrows(color_options, "Select your favorite color", allow_back=True)
50+
if color is None: # Cancelled
51+
print("Wizard cancelled!")
52+
return
53+
elif color is BACK: # Go back
54+
step = 2
55+
continue
56+
step = 4
57+
58+
elif step == 4:
59+
# Final step - show results
60+
print("\n=== Results ===")
61+
print(f"Name: {name}")
62+
print(f"Age: {age}")
63+
print(f"Favorite Color: {color}")
64+
return
65+
66+
67+
if __name__ == "__main__":
68+
simple_wizard_with_back()

pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ dependencies = [
2929
"pygments>=2.19.2",
3030
"pyyaml>=6.0.1",
3131
"python-json-logger==2.0.7",
32+
"prompt-toolkit>=3.0.0",
3233
"requests<3,>=2.32.2",
3334
"rich>=13.7.1",
35+
"typer>=0.12.0",
3436
"anyascii>=0.3.3,<1.0",
3537
"boto3==1.35.74",
3638
"datasets>=4.0.0",
@@ -52,6 +54,9 @@ dependencies = [
5254
"ruff==0.12.3",
5355
]
5456

57+
[project.scripts]
58+
data-designer = "data_designer.cli:main"
59+
5560
[dependency-groups]
5661
dev = [
5762
"jsonpath-ng==1.5.3",

src/data_designer/cli/__init__.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
import typer
5+
6+
# Initialize Typer app with custom configuration
7+
app = typer.Typer(
8+
name="data-designer",
9+
help="Data Designer CLI - Configure model providers and models for synthetic data generation",
10+
add_completion=False,
11+
no_args_is_help=True,
12+
rich_markup_mode="rich",
13+
)
14+
15+
# Import and register command groups
16+
# We import here to avoid circular dependencies
17+
from data_designer.cli.commands import list as list_cmd
18+
from data_designer.cli.commands import models, providers, validate
19+
20+
# Create config subcommand group
21+
config_app = typer.Typer(
22+
name="config",
23+
help="Manage configuration files",
24+
no_args_is_help=True,
25+
)
26+
config_app.command(name="providers", help="Configure model providers interactively")(providers.providers_command)
27+
config_app.command(name="models", help="Configure models interactively")(models.models_command)
28+
config_app.command(name="list", help="List current configurations")(list_cmd.list_command)
29+
config_app.command(name="validate", help="Validate configuration files")(validate.validate_command)
30+
31+
app.add_typer(config_app, name="config")
32+
33+
34+
def main() -> None:
35+
"""Main entry point for the CLI."""
36+
app()
37+
38+
39+
if __name__ == "__main__":
40+
main()
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0

0 commit comments

Comments
 (0)