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

Inherit all/some tasks from included file #572

Closed
fgblomqvist opened this issue Sep 16, 2021 · 3 comments
Closed

Inherit all/some tasks from included file #572

fgblomqvist opened this issue Sep 16, 2021 · 3 comments

Comments

@fgblomqvist
Copy link

fgblomqvist commented Sep 16, 2021

In my shared Taskfiles, I have two types of tasks:

  • Ones that are primarily "utility" tasks that are meant to be used by other tasks
  • Ones that are primarily first-degree tasks that are meant to be used by users

Right now I can include a Taskfile by doing something like (the extended format):

includes:
  shared:
    taskfile: ../../Taskfile.yml

However, in order for the user to be able to use the first-degree shared tasks I still have to redeclare them:

tasks:
  install: 
    - task: shared:install

This is tedious and can result in a lot of boilerplate.
Therefore, I think it would be handy to be able to directly inherit some/all of the tasks from an included file.

It could look like this:

includes:
  shared:
    taskfile: ../../Taskfile.yml
    inherit: true

or if you only want to inherit some of the tasks:

includes:
  shared:
    taskfile: ../../Taskfile.yml
    inherit: [install, test]

And then a user would be able to just call task install which would execute a task that would be equivalent to:

install:
  - task:
    - shared:install

However, inside the taskfile, you'd still have to use the namespace:

foo:
  - do things
  - task: shared:install
  - do more things

Any thoughts?

@fgblomqvist fgblomqvist added the type: feature A new feature or functionality. label Sep 16, 2021
@fgblomqvist fgblomqvist changed the title Inherit all tasks from included file Inherit all/some tasks from included file Sep 16, 2021
@tylermmorton
Copy link
Contributor

tylermmorton commented Jan 17, 2022

Hi @fgblomqvist, thank you for the feature request. I could see it being useful to select which tasks are included from files. It could prevent polluting the task list if you have a utility Taskfile that you include in many of your other Taskfiles.

includes:
  util:
    taskfile: "../util/Taskfile.yml"
    include: [clean, install]

tasks:
  setup:
    - task: util:clean
    - task: util:install

Are you also suggesting the ability to inline certain tasks to remove the parent namespace? This has been suggested before in #273

includes:
  util:
    taskfile: "../util/Taskfile.yml"
    include: [clean, install]
    inline: true

tasks:
  setup:
    - task: clean
    - task: install

@fgblomqvist
Copy link
Author

Ah yes my bad, I did not find that one when I looked before posting this. That is indeed pretty much what I was looking for 🙂 . But yeah having the ability to only import certain tasks could also be useful in combination.

@andreynering
Copy link
Member

Since this is a duplicate of #273 I'm closing this one.

@pd93 pd93 removed the type: feature A new feature or functionality. label Dec 16, 2024
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

No branches or pull requests

4 participants