Fixed caret position for append transforms
This commit is contained in:
parent
44a5b664a0
commit
9f14a895fa
3 changed files with 46 additions and 6 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue