From fdd9d9e8de38213435ffcd59660a1c30144fb025 Mon Sep 17 00:00:00 2001 From: Swastik Date: Fri, 26 Jul 2024 16:44:54 +0530 Subject: [PATCH 1/2] feat: warn when using SET commands not being the top decl --- evaluator.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/evaluator.go b/evaluator.go index 9c7a8448a..0ae205d5c 100644 --- a/evaluator.go +++ b/evaluator.go @@ -152,6 +152,10 @@ func Evaluate(ctx context.Context, tape string, out io.Writer, opts ...Evaluator // // We should remove if isSetting statement. isSetting := cmd.Type == token.SET && cmd.Options != "TypingSpeed" + + if isSetting { + fmt.Println(ErrorStyle.Render(fmt.Sprintf("WARN: Set %s %s has to be a top declaration of the file", cmd.Options, cmd.Args))) + } if isSetting || cmd.Type == token.REQUIRE { fmt.Fprintln(out, Highlight(cmd, true)) continue From dbaf475d89ee0ed9fa16b829ec03420b9f3b914d Mon Sep 17 00:00:00 2001 From: bashbunni Date: Fri, 18 Oct 2024 14:27:38 -0700 Subject: [PATCH 2/2] refactor: adjust wording --- evaluator.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/evaluator.go b/evaluator.go index 0ae205d5c..1da005de1 100644 --- a/evaluator.go +++ b/evaluator.go @@ -154,7 +154,7 @@ func Evaluate(ctx context.Context, tape string, out io.Writer, opts ...Evaluator isSetting := cmd.Type == token.SET && cmd.Options != "TypingSpeed" if isSetting { - fmt.Println(ErrorStyle.Render(fmt.Sprintf("WARN: Set %s %s has to be a top declaration of the file", cmd.Options, cmd.Args))) + fmt.Println(ErrorStyle.Render(fmt.Sprintf("WARN: 'Set %s %s' has been ignored. Move the directive to the top of the file.\nLearn more: https://github.com/charmbracelet/vhs#settings", cmd.Options, cmd.Args))) } if isSetting || cmd.Type == token.REQUIRE { fmt.Fprintln(out, Highlight(cmd, true))