Fixed caret position for append transforms
All checks were successful
Build / build (push) Successful in 39s
Release Build / build (push) Successful in 3m59s

This commit is contained in:
Leon Mika 2026-05-04 22:00:12 +10:00
parent 44a5b664a0
commit 9f14a895fa
3 changed files with 46 additions and 6 deletions

View file

@ -14,6 +14,7 @@ import (
"text/template"
"github.com/google/uuid"
"gopkg.in/yaml.v3"
"ucl.lmika.dev/ucl"
)
@ -60,14 +61,25 @@ var TextFilters = map[string]TextProcessor{
return TextFilterResponse{Output: strings.ToLower(input)}, nil
},
},
"quote": {
Label: "String: Quote",
Filter: func(ctx context.Context, input string) (resp TextFilterResponse, err error) {
return TextFilterResponse{Output: strconv.Quote(input)}, nil
},
},
"unquote": {
Label: "String: Unquote",
Filter: func(ctx context.Context, input string) (resp TextFilterResponse, err error) {
out, err := strconv.Unquote(input)
endNL := ""
if strings.HasSuffix(input, "\n") {
endNL = "\n"
}
out, err := strconv.Unquote(strings.TrimSpace(input))
if err != nil {
return TextFilterResponse{}, err
}
return TextFilterResponse{Output: out}, nil
return TextFilterResponse{Output: out + endNL}, nil
},
},
"join-lines-with-commas": {
@ -176,6 +188,20 @@ var TextFilters = map[string]TextProcessor{
},
},
"uuid": {
Label: "Generate: UUID v4",
Filter: func(ctx context.Context, input string) (resp TextFilterResponse, err error) {
u, err := uuid.NewRandom()
if err != nil {
return TextFilterResponse{}, fmt.Errorf("failed to generate UUID: %w", err)
}
return TextFilterResponse{
Output: u.String(),
Append: true,
}, nil
},
},
"lines": {
Label: "Lines: Count",
Analyze: func(ctx context.Context, input string) (result string, err error) {