From 1a12b94bd3aba4cdf2561d3e53c1b0863d8c6bd0 Mon Sep 17 00:00:00 2001 From: Pete Davison Date: Thu, 30 Nov 2023 01:56:30 +0000 Subject: [PATCH] feat: new dynamic variable syntax --- taskfile/var.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/taskfile/var.go b/taskfile/var.go index b455c3c2..536b566c 100644 --- a/taskfile/var.go +++ b/taskfile/var.go @@ -2,6 +2,7 @@ package taskfile import ( "fmt" + "strings" "gopkg.in/yaml.v3" @@ -84,6 +85,13 @@ func (v *Var) UnmarshalYAML(node *yaml.Node) error { if err := node.Decode(&value); err != nil { return err } + // If the value is a string and it starts with $, then it's a shell command + if str, ok := value.(string); ok { + if str, ok = strings.CutPrefix(str, "$"); ok { + v.Sh = str + return nil + } + } v.Value = value return nil }