Repository navigation
Add list variables: listvar and splice - #15
Merged
Merged
Conversation
- `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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the list variables from #11, deliberately in a narrow form:
listvar(name), asstdoutof 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:requires, the task depends on all of them.innerjoin are now an error. Before,zipsilently dropped the extra items, which matters more when lists are computed.What's refused, with a clear error:
listvaranywhere other thanstdout;splicein targets,stdinorpath;${name};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
splicein 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.requires: a task with aspliceinrequiresdepends on the list variable, and the splice is expanded when the task is created.Tests
requires(including rerunning when a spliced dependency changes), empty lists, and each error.python -c, so they also run on Windows.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