Skip to content

Add list variables: listvar and splice - #15

Merged
jhidding merged 1 commit into
mainfrom
feature/list-variables
Nov 15, 2026
Merged

jhidding merged 1 commit into
mainfrom
feature/list-variables

Conversation

@jhidding

Copy link
Copy Markdown
Contributor

Summary

Implements the list variables from #11, deliberately in a narrow form:

  • listvar(name), as stdout of a task, stores the output split into lines as a list. Empty lines are skipped.
  • splice(name), as a whole element of a list, inserts the elements of that list:
    • in template call arguments, it creates a task for each element;
    • in requires, the task depends on all of them.
  • Strict inner join: lists of different lengths in an inner join are now an error. Before, zip silently dropped the extra items, which matters more when lists are computed.

What's refused, with a clear error:

  • listvar anywhere other than stdout;
  • splice in targets, stdin or path;
  • a list variable used in a string as ${name};
  • splicing a variable that isn't a list.

There are no string or filename functions. The documentation recommends having the listing print what the template needs, and generating an include for anything more involved.

A task whose only target is a list variable has no file targets, so it runs every time and new items are found. The tasks made for each item stay lazy.

Implementation

  • Expanding calls: calls with a splice in their arguments wait until the program's tasks and includes are added, the same way calls to templates from includes already do. Their list variables are then computed and spliced in.
  • Expanding requires: a task with a splice in requires depends on the list variable, and the splice is expanded when the task is created.

Tests

  • New tests cover splicing into call arguments and into requires (including rerunning when a spliced dependency changes), empty lists, and each error.
  • They use python -c, so they also run on Windows.
  • The documented example (examples/list_variables.toml, copying figures) was tested by hand: unchanged figures aren't copied again, and a new figure is picked up.

🤖 Generated with Claude Code

- `listvar(name)` as `stdout` stores the output of a task, split into
  lines, as a list.
- `splice(name)` as an element of a list, in `requires` or in template
  call arguments, inserts the elements of that list.
- An inner join of lists with different lengths is an error, instead of
  silently dropping items.

Addresses #11.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jhidding
jhidding merged commit ae74f59 into main Nov 15, 2026
9 checks passed
@jhidding
jhidding deleted the feature/list-variables branch November 15, 2026 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant