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

Add --global (-g) flag #1029

Merged
merged 1 commit into from
Mar 9, 2023
Merged

Add --global (-g) flag #1029

merged 1 commit into from
Mar 9, 2023

Conversation

andreynering
Copy link
Member

This is an idea that has been in my mind for some time. Feedback and/or suggestions are welcome.

In short, this adds the ability to run a Taskfile from your home directory ($HOME/Taskfile.yaml), meaning that you can now have a Taskfile that you can run from anywhere with a simple task -g ....

@andreynering andreynering requested a review from pd93 March 2, 2023 01:51
@andreynering andreynering self-assigned this Mar 2, 2023
Copy link
Member

@pd93 pd93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a downside to this. Its simple and I'm sure lots of people will find this useful.

Worth noting that you can get this behaviour today by putting a Taskfile in $HOME and running task (without -g) if there are no other Taskfiles between $PWD and $HOME. However being able to call it from inside a project containing a Taskfile is super useful.

Its a little difficult to make tests for this since it relies on os.UserHomeDir(), but its also quite simple code - so maybe we don't need one? We could mock out the call to os.UserHomeDir though if you think its worth it.

This will run a Taskfile from the home directory, i.e., `$HOME/Taskfile.yml`.
@andreynering
Copy link
Member Author

Thanks for your comments @pd93.

The fact is that we don't have any test for cmd/task/task.go at the moment. Perhaps someday we could try extract some behavior out of the main package and write a few simple tests.

And yes, -g is useful because you can run even when the current directory has another Taskfile.

@andreynering andreynering merged commit 9c84485 into master Mar 9, 2023
@andreynering andreynering deleted the global-flag branch March 9, 2023 02:21
@pd93 pd93 mentioned this pull request Jul 19, 2023
@pd93 pd93 added type: feature A new feature or functionality. and removed type: proposal labels Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature A new feature or functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants