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

Including taskfiles on root namespace / Inline includes #1378

Closed
BrunoSilvaFreire opened this issue Oct 22, 2023 Discussed in #595 · 1 comment
Closed

Including taskfiles on root namespace / Inline includes #1378

BrunoSilvaFreire opened this issue Oct 22, 2023 Discussed in #595 · 1 comment

Comments

@BrunoSilvaFreire
Copy link

Following this discussion:

Discussed in #595

Originally posted by back-2-95 November 1, 2021
Currently including a taskfile will result namespacing for commands in that file. Example:

includes:
  foobar: ./tools/task/Taskfile.yml

Will have commands liketask foobar:something.

Is it be possible to include taskfile and declare tasks to be without namespace?

Other thing:

Can including be optional? E.g. if VARIABLE=1 then include some taskfile.

This usecase came up on me today and it'd be great to have this option.
For example, I'd like to group my tasks over multiple files according to functionality, but not add a namespace to them:

# tasks/Taskfile.cron.yml

version: "3"
tasks:
  install-cronjob:
    desc: "Installs a cron job to start the scrapping service at a specific schedule (Production)"
    cmds:
      - mkdir -p ~/log/cityscrape
      - echo '{{.CRON_SCHEDULE}} cd {{.PWD}} && task up-distributed-prod -- --build >> ~/log/cityscrape/house-$(date +\%Y\%m\%d\%H\%M\%S).log 2>&1' | crontab -

  uninstall-cronjob:
    desc: "Removes the installed cron job"
    cmds:
      - crontab -r
      - echo "Cron job has been removed."

  reinstall-cronjob:
    desc: "Reinstalls the cron job"
    deps:
      - uninstall-cronjob
      - install-cronjob

# ----------------------
# Taskfile.yml
version: "3"
includes:
  cron:
    taskfile: tasks/Taskfile.cron.yml

I could just call my cron tasks install, uninstall, reinstall and invoke them with the cron namespace, but it feels like workaround and causes ambiguous task names. Naming a task "install" doesn't reflect that it actually only install's the cronjob. I'd like to be able to specify tasks directly onto the root namespace over different files. This way I can have separated files for each functionality, but also have the conveniance of having all of them available on the root namespace.

@task-bot task-bot added the state: needs triage Waiting to be triaged by a maintainer. label Oct 22, 2023
@BrunoSilvaFreire
Copy link
Author

Closing because just noticed the discussion at #273

@BrunoSilvaFreire BrunoSilvaFreire closed this as not planned Won't fix, can't repro, duplicate, stale Oct 22, 2023
@task-bot task-bot removed the state: needs triage Waiting to be triaged by a maintainer. label Oct 22, 2023
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

2 participants