Skip to content

Commit

Permalink
feat: warn when using SET commands not being the top decl (#508)
Browse files Browse the repository at this point in the history
* feat: warn when using SET commands not being the top decl

* refactor: adjust wording

---------

Co-authored-by: bashbunni <[email protected]>
  • Loading branch information
Delta456 and bashbunni authored Oct 18, 2024
1 parent 3fe2446 commit 2ff7bbd
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions evaluator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 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))
continue
Expand Down

0 comments on commit 2ff7bbd

Please sign in to comment.