Comments (11)
Done. Note that I might now be leaning towards adding args anyhow... Se #31 for why.
from task.
This is currently only partially supported.
You can specify globbing in sources
and generates
, but Task will rerun everything once any file change.
No way to do 1-to-1 file mapping yet.
from task.
In Makefiles, this feature is not only to avoid unnecessary work, as it also allows basic templating of tasks for use with different parameters.
E.g. if we where to produce a deb package for N binaries, it would be cool if there was a way to allow for templating / task reusability.
from task.
Could a syntax like this work?
template-task:
args:
- FILENAME
cmds:
- markdown {{.FILENAME}}.md > {{.FILENAME}}.html
sources:
- {{.FILENAME}}.md
generates:
- {{.FILENAME}}.html
The template task may only be used in another task. E.g. like this:
using-template:
cmds:
- ^template-task FILENAME=index
A more complex usage would want to call the template-task with either a list of input parameters, or maybe even somehow retrieve this list via a glob pattern!
from task.
I guess the glob pattern could be retrieved via a dynamic variable... FILENAMES=$ls *.md | sed 's/\.md$//g'
. Of course, this might make it OS specific...
UPDATE: Maybe better to do this using a Go template variable filter. Eg. a replace method supporting basic regex.
from task.
Rather adding yet-another-keyword args
, I guess we could also use the existing vars
, the only difference being that vars might be set when running sub-tasks? And that tasks are cached according to the variable values as well as the task name?
from task.
@smyrman I liked the idea! Yes, I would use existing vars
instead of args
.
Could you please open another issue for task parameters?
from task.
@smyrman Thanks
from task.
That would work but it would recompile every Markdown file any time any file in sources/*.md updated. Instead what we want is to establish that 1:1 mapping, done this way:
public/%.html: sources/%.md
markdown $< > $@
I guess this is now possible via task parameters.
build:
deps:
- task: tmpl/md2html:
vars:
NAME: index
- task: tmpl/md2html:
vars:
NAME: about
- task: tmpl/md2html:
vars:
NAME: blog
tmpl/md2html:
cmds:
- markdown sources/{{.NAME}}.md > public/{{.NAME}}.html
sources:
- sources/{{.NAME}}.md
generates:
- public/{{.NAME}}.html
For more compact syntax, use the YAML-supported inline JSON vars: {"NAME": "index"}
,
UPDATE: fix typo ( use task:
not cmd:
as prefix when calling tasks)
from task.
Anyway, maybe the ticket could be closed?
from task.
@smyrman OK, this is partly implemented. Not completetly, since it can't automatically infer sources
globs to commands like Make, but I'll close in favor of #82
from task.
Related Issues (20)
- Provide some typical cases of practical applications as reference for configuration or various usages HOT 2
- Unable to override dotenv file loaded using $ENV value, as per the example in the docs HOT 1
- When calling a subtask, the passed variable cannot directly overwrite the value in the subtask, which is inconsistent with the document description. HOT 1
- for loop does not take effect in deps HOT 1
- The for loop does not support specifying multiple commands HOT 1
- Template-related errors are difficult to understand
- Add `q` alias for `shellQuote` template function? HOT 2
- Exclude doesn't support globbing HOT 1
- Variables are initialized at start of taskfile and not when I actually need them to be initialized
- fatal error: concurrent map writes HOT 3
- Cannot include multiple time the same Taskfile with differents namespaces HOT 7
- shell opt in variables sh not working
- using variable in template error
- Request: Docs section listing all template functions available HOT 4
- Vars can be included in other vars, but env vars not in other env vars
- Add TASK_EXECUTABLE_PATH variable
- Suppress signal received message HOT 1
- Add support for faint colors HOT 2
- Multiline commands for dynamic vars HOT 2
- Declaration order matters when nesting dynamic vars HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from task.