DemoGen.Runner (DemoGen v0.2.0)
Summary
Functions
Runs a demo from a demo file with the given options.
Runs a demo from a demo file with an explicit repository and command map.
Functions
Runs a demo from a demo file with the given options.
This function parses and executes commands from a demo file within a repository
transaction. It builds a command map from the provided module prefixes and
delegates to run_demo/3.
Parameters
demo_file- Path to the demo file containing commands to executeopts- Keyword list of options::repo- Repository module (required):prefix- Module prefix(es) for command mapping (required)
Returns
The result of the repository transaction containing the executed commands, or an error tuple if parsing fails.
Examples
iex> DemoGen.Runner.run_demo("demo.dgen", repo: MyRepo, prefix: MyApp.Demo.Commands)
{:ok, %{time: ~U[...], ...}}
Runs a demo from a demo file with an explicit repository and command map.
This is the lower-level function that performs the actual demo execution. It parses the demo file and executes each command within a repository transaction, maintaining execution context including timestamps and symbol state.
Parameters
demo_file- Path to the demo file containing commands to executerepo- Repository module that implements Ecto.Repo behaviourcommand_map- Map of command names to their corresponding command modules
Returns
{:ok, context}- Success with final execution context containing timestamps, command map, repo, and accumulated symbols{:error, reason}- Error if file parsing fails or transaction is rolled back
Examples
iex> command_map = %{"create_user" => MyApp.Demo.Commands.CreateUser}
iex> DemoGen.Runner.run_demo("demo.dgen", MyRepo, command_map)
{:ok, %{time: ~U[2024-01-01 12:00:00Z], symbols: %{user_id: 123}, ...}}