Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

override dist taskfile #1873

Open
lrob opened this issue Oct 21, 2024 · 3 comments
Open

override dist taskfile #1873

lrob opened this issue Oct 21, 2024 · 3 comments
Labels
state: needs triage Waiting to be triaged by a maintainer.

Comments

@lrob
Copy link

lrob commented Oct 21, 2024

If not already possible, and I missed it, it would be very useful to be able to override only certain fields of a taskfile.dist.yml with a local taskfile.yml. Just like in docker compose with docker-compose.override.yml. Here is the documentation for it.

This would have several advantages: the most important, I think, are:

  1. The taskfile.yml would usually be very short, because the fields to be overridden are usually only a few.
  2. if any part of the dist file is modified, this is automatically inherited by the local taskfile.yml.
@task-bot task-bot added the state: needs triage Waiting to be triaged by a maintainer. label Oct 21, 2024
@trulede
Copy link

trulede commented Jan 3, 2025

@lrob You could use the existing include mechanism to achieve the same effect.

The specification of the included taskfile name uses a template mechanism, so it would even be possible to select which file to include at runtime. For example:

version: '3'

includes:
  lib:
    taskfile: ./Taskfile.{{REL}}.yml    //resolves to a taskfile containing task 'do_stuff'
    flatten: true                              // no namespace, just call task'do_stuff' directly

Then run task: REL=debug task do_stuff ... or similar. There is a lot of possibility from there.

https://taskfile.dev/usage/#flatten-includes

@lrob
Copy link
Author

lrob commented Jan 7, 2025

Hi, thanks for your answer.
I think that I cannot achieve what I need with the include feature. I provide an example of what I would like to achieve.
Let's say that this is the content of the taskfile.dist.yml:

version: '3'

tasks:
  greet:
    cmds:
      - echo $GREETING
    env:
      GREETING: Hey, there!

if we locally want a different greeting, so far, we need to copy the tasfkile.dist.yml in a new file named taskfile.yaml with this content:

version: '3'

tasks:
  greet:
    cmds:
      - echo $GREETING
    env:
      GREETING: Hello!

what I would like to have is a mechanism that allows to override only some fields of the tasfile.dist.yml by creating a file named (for example) taskfile.override.yaml with the following content:

version: '3'

tasks:
  greet:
    env:
      GREETING: Hello!

@trulede
Copy link

trulede commented Jan 7, 2025

@lrob take a look at dotenv. Same strategy as before. You can certainly do these kinds of things already, however take a little more time to learn how the various mechanism work, and how you problem can be expressed to take advantage of the existing capabilities of Task. You will find a working solution for sure!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state: needs triage Waiting to be triaged by a maintainer.
Projects
None yet
Development

No branches or pull requests

3 participants