feat: add --examples and --example flags (#23) - #30
Conversation
New users had no built-in way to discover working workflow examples or bootstrap a starter file. Add two flags following the existing --schema / --version eager-callback pattern. Changes: - Add src/flowsh_cli/examples.py: single source of truth for three example tiers (simple, medium, sophisticated) with helpers examples_index() and example_yaml() - Add --examples (bool) to cli.py: prints the index and exits - Add --example NAME (str) to cli.py: prints the named YAML and exits, exits 1 with a clear error on unknown names - Update EXPECTED_HELP constant and add 5 new tests covering listing, printing, parse validation, dry-run, and unknown-name error Fixes #23
Automated Code ReviewSummaryThe implementation correctly follows the investigation artifact plan, using two flags ( FindingsStrengths
Suggestions (non-blocking)
SecurityNo security concerns — new code is read-only data + print, no file I/O, no subprocess calls. Checklist
Self-reviewed by Claude — ready for human review |
PR #30 Review: feat: add --examples and --example flags (#23)Note: This PR is already MERGED. This is a historical/post-merge review. Author: tbrandenburg SummaryThis PR resolves issue #23 by adding two new CLI flags to the
The implementation mirrors the existing Validation Results
Issues Found
Detailed FindingsMediumM1 — def examples_index() -> str:
lines = ["Available examples (use --example <name> to print runnable YAML):\n"]
for name, (desc, step_types, _) in EXAMPLES.items():
lines.append(f" {name:<14}{desc}")
lines.append(f" {'':14}Step types: {step_types}\n")
return "\n".join(lines)Each entry's second line ends with Recommendation: return "\n".join(lines).rstrip("\n") + "\n"Or strip trailing Low / SuggestionsS1 — Tuple positional indexing on The dict stores from typing import NamedTuple
class ExampleEntry(NamedTuple):
description: str
step_types: str
yaml: str
EXAMPLES: dict[str, ExampleEntry] = { ... }This is a non-blocking suggestion — the current form is concise and works fine for a static data module. S2 —
Strengths
RecommendationAPPROVE (retrospective). This is a clean, minimal, well-tested addition. It follows existing patterns exactly, introduces no new risk surface, and directly resolves the discoverability problem stated in issue #23. The one medium finding (trailing newline fragility) is worth addressing in a follow-up but does not affect current behavior or test results. Review performed post-merge as historical analysis. All validation run on branch |
Summary
New users had no built-in way to discover working workflow examples or bootstrap a starter file. This PR adds a
--examplesflag to list available examples and--example NAMEto print a specific runnable YAML to stdout, following the existing--schema/--versioneager-callback pattern.Root Cause
No discoverability mechanism existed for working workflow YAML. The #1 friction point (vars values are shell commands, not literals) had no inline documentation path.
Changes
src/flowsh_cli/examples.pysrc/flowsh_cli/cli.py--examples(list index) and--example NAME(print YAML) flagstests/test_workflow_to_harness.pyTesting
Validation
make qa # 104 passedIssue
Fixes #23
Implementation Details
Deviations from plan
--examplesbool +--example NAMEstr) instead of a single optional-value--examples [name]flag — exactly as recommended in the investigation artifact, since Typer does not support optional-value options natively.Automated implementation from investigation artifact