-
-
Notifications
You must be signed in to change notification settings - Fork 646
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
[WIP] Allow shorter syntax for tasks with default configuration #240
Conversation
Hi @jaedle, thanks for opening this PR! Regarding 1) and 2), I think would not be a that big deal to allow the shorter syntax on v2, too. (Even then, this should still target the That said, if we find a easy/right way to only allow it on v3, it'd be the ideal scenario. If you're unsure about how to do that, it could be pulled to a future fix/PR. Regarding 3), we already do that for other data structures. In short, what you should do is:
Does that makes sense? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job so far 👏 👏 👏
I did a suggestion on how to simplify func (t *Task) UnmarshalYAML
a bit, though. Hope that makes sense.
@@ -40,3 +40,61 @@ func (tf *Taskfile) UnmarshalYAML(unmarshal func(interface{}) error) error { | |||
} | |||
return nil | |||
} | |||
|
|||
func (t *Task) UnmarshalYAML(unmarshal func(interface{}) error) error { | |||
var task struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @jaedle,
IMHO you don't need to copy the entire task struct into this function. Just try to marshal the string
and []string
types first, and none work then unmarshal to the t
variable directly. 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, I just remembered that we also have alternative command syntaxes, like { cmd: "echo foo", silent: true }
for example.
That's easy to do, though. Just check for taskfile.Cmd
and []taskfile.Cmd
instead of for string
and []string
. All variations should just work.
version: '3' | ||
|
||
tasks: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -20,5 +20,5 @@ type Task struct { | |||
Silent bool | |||
Method string | |||
Prefix string | |||
IgnoreError bool `yaml:"ignore_error"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the suggestion made on func (t *Task) UnmarshalYAML
, we should re-add this reflect tag.
See #194
After doing some coding/research how to implement this, I have a few questions:
internal/taskfile/taskfile.go
for disallow a shorter syntax for older taskfile versions?(I will squash this branch before review)