Have made some large improvements
All checks were successful
Build / build (push) Successful in 2m48s
All checks were successful
Build / build (push) Successful in 2m48s
- Added support for multiple cursors - Enabled wrapping - Added uppercase, lowercase, and lorem ipsum support - Added support for processing only selected ranges
This commit is contained in:
parent
a047d89dad
commit
3a23118036
7 changed files with 99 additions and 18 deletions
|
|
@ -1,22 +1,46 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type TextFilter func(input string) (output string, err error)
|
||||
|
||||
var TextFilters = map[string]TextFilter{
|
||||
"upper-case": func(input string) (output string, err error) {
|
||||
return strings.ToUpper(input), nil
|
||||
},
|
||||
"lower-case": func(input string) (output string, err error) {
|
||||
return strings.ToLower(input), nil
|
||||
},
|
||||
"unquote": func(input string) (output string, err error) {
|
||||
return strconv.Unquote(input)
|
||||
},
|
||||
"format-json": func(input string) (output string, err error) {
|
||||
var dst bytes.Buffer
|
||||
if err := json.Indent(&dst, []byte(input), "", " "); err != nil {
|
||||
return "", err
|
||||
|
||||
scnr := bufio.NewScanner(strings.NewReader(input))
|
||||
for scnr.Scan() {
|
||||
line := scnr.Text()
|
||||
if err := json.Indent(&dst, []byte(line), "", " "); err == nil {
|
||||
dst.WriteString("\n")
|
||||
} else {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
|
||||
return dst.String(), nil
|
||||
},
|
||||
"lorem-ipsum": func(input string) (output string, err error) {
|
||||
return "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor " +
|
||||
"incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud " +
|
||||
"exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure " +
|
||||
"dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. " +
|
||||
"Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt " +
|
||||
"mollit anim id est laborum.", nil
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue