Skip to content

Implement CLI entry point with inspect command #44

@dgenio

Description

@dgenio

Context

Split from #33 (CLI meta-issue). This is the first CLI issue — it establishes the entry point and the simplest command.

What to do

1. Create CLI entry point

Create chainweaver/cli.py using argparse (stdlib, no extra dependency):

def main() -> None:
    parser = argparse.ArgumentParser(prog="chainweaver", description="ChainWeaver CLI")
    subparsers = parser.add_subparsers(dest="command")
    
    # inspect command
    inspect_parser = subparsers.add_parser("inspect", help="Show flow structure")
    inspect_parser.add_argument("flow_name", help="Name of the flow to inspect")
    inspect_parser.add_argument("--format", choices=["table", "json"], default="table")
    
    args = parser.parse_args()
    # dispatch...

2. Register entry point in pyproject.toml

[project.scripts]
chainweaver = "chainweaver.cli:main"

3. Implement inspect command

chainweaver inspect <flow_name> prints flow structure:

  • Flow name, description, deterministic flag
  • Steps table: index, tool_name, input_mapping
  • --format json outputs machine-readable JSON

Files to create/modify

  • chainweaver/cli.py — new CLI module
  • pyproject.toml — add [project.scripts] entry
  • tests/test_cli.py — new test file

Acceptance Criteria

  • chainweaver CLI entry point is registered and callable after pip install -e .
  • chainweaver inspect <flow_name> prints flow structure (steps, mappings, metadata)
  • --format json produces valid JSON output
  • --format table is the default and produces human-readable table output
  • Exit codes: 0 = success, 1 = error
  • At least 3 test cases: inspect valid flow, inspect missing flow, JSON output format

Out of Scope

  • validate, check commands (→ separate issue)
  • viz command (→ separate issue)
  • execute, suggest commands (deferred)

Dependencies

None — uses in-memory registry and flows.


Part of CLI split from #33. See also: validate/check CLI, viz CLI.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions