Skip to content

Add an --examples parameter #23

Description

@tbrandenburg

Summary

Add --examples [name] to flowsh-cli.

  • Bare --examples prints a human-readable index of available examples.
  • --examples <name> prints a single runnable YAML to stdout — pipeable into a file and directly usable.

User journey

Step 1 — Discover what examples exist

$ uvx flowsh-cli --examples

Available examples (use --examples <name> to print runnable YAML):

  simple        Vars + sequential bash steps
                Step types: vars, bash

  medium        Params + vars + bash + agent with prompt expansion
                Step types: vars, bash, agent

  sophisticated Params + vars + bash + agent + for + parallel + file handoff
                Step types: vars, bash, agent, for, parallel

Step 2 — Print a specific example

$ uvx flowsh-cli --examples simple
workflows:
  - id: wf_simple
    name: Simple example — vars and bash

    steps:
      - type: vars
        name: Capture date
        values:
          TODAY: date -u +%F       # shell command; stdout becomes the variable

      - type: bash
        name: Greet
        run: echo "Hello, today is $TODAY"

      - type: bash
        name: Done
        run: echo "Workflow complete"

Step 3 — Save and run

uvx flowsh-cli --examples simple > demo.yml
uvx flowsh-cli demo.yml --dry-run
uvx flowsh-cli demo.yml --force
bash .harness/demo.sh

Step 4 — Unknown name gives a clear error

$ uvx flowsh-cli --examples typo
Error: unknown example 'typo'. Available: simple, medium, sophisticated

Three example tiers

simple — vars + sequential bash

Explicitly shows that vars values are shell commands whose stdout becomes the variable — not literal strings. This is the most common point of confusion.

workflows:
  - id: wf_simple
    name: Simple example — vars and bash
    steps:
      - type: vars
        values:
          TODAY: date -u +%F
      - type: bash
        run: echo "Today is $TODAY"

medium — params + vars + bash + agent with prompt expansion

Shows params for required workflow inputs and expandPrompt: true to interpolate ${VAR} tokens from vars into an agent prompt.

workflows:
  - id: wf_medium
    name: Medium example — params, vars, agent
    params:
      - name: TOPIC
        description: Subject to summarise
        required: true
    steps:
      - type: vars
        values:
          TODAY: date -u +%F
      - type: bash
        run: echo "Running on $TODAY for topic: $TOPIC"
      - type: agent
        expandPrompt: true
        prompt: |
          Today is ${TODAY}. Write a one-paragraph summary about ${TOPIC}.

sophisticated — params + vars + bash + agent + for + parallel + file handoff

Demonstrates for iterating a newline-delimited var, parallel branches with a join barrier, and data transfer between steps via a shared temp file.

workflows:
  - id: wf_sophisticated
    name: Sophisticated example — for, parallel, file handoff
    params:
      - name: ITEMS
        description: Newline-delimited list of items to process
        required: true
    steps:
      - type: vars
        values:
          OUTFILE: mktemp
      - type: parallel
        steps:
          - type: bash
            run: echo "worker A started"
          - type: bash
            run: echo "worker B started"
      - type: for
        in: ITEMS
        item: ITEM
        steps:
          - type: bash
            run: echo "$ITEM" >> "$OUTFILE"
      - type: agent
        expandPrompt: true
        prompt: |
          The file ${OUTFILE} contains one processed item per line.
          Summarise the results.

Single source of truth

  • All examples live in one place in the codebase (e.g. src/flowsh_cli/examples.py).
  • Each example is validated via dry-run as part of the E2E test suite — no drift possible.
  • --examples <name> renders from that same source.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions