get rid of utils.Cut since we can now rely on strings.Cut instead

This commit is contained in:
Kovid Goyal
2023-03-04 13:37:55 +05:30
parent defac0c061
commit a2887bb9e0
12 changed files with 24 additions and 35 deletions

View File

@@ -3,13 +3,13 @@
package at
import (
"kitty/tools/utils"
"strings"
)
func parse_key_val_args(args []string) map[escaped_string]escaped_string {
ans := make(map[escaped_string]escaped_string, len(args))
for _, arg := range args {
key, value, found := utils.Cut(arg, "=")
key, value, found := strings.Cut(arg, "=")
if found {
ans[escaped_string(key)] = escaped_string(value)
} else {

View File

@@ -80,7 +80,7 @@ func get_pubkey(encoded_key string) (encryption_version string, pubkey []byte, e
return
}
}
encryption_version, encoded_key, found := utils.Cut(encoded_key, ":")
encryption_version, encoded_key, found := strings.Cut(encoded_key, ":")
if !found {
err = fmt.Errorf("KITTY_PUBLIC_KEY environment variable does not have a : in it")
return

View File

@@ -48,7 +48,7 @@ func set_color_in_color_map(key, val string, ans map[string]any, check_nullable,
func parse_colors_and_files(args []string) (map[string]any, error) {
ans := make(map[string]any, len(args))
for _, arg := range args {
key, val, found := utils.Cut(strings.ToLower(arg), "=")
key, val, found := strings.Cut(strings.ToLower(arg), "=")
if found {
err := set_color_in_color_map(key, val, ans, true, false)
if err != nil {
@@ -63,7 +63,7 @@ func parse_colors_and_files(args []string) (map[string]any, error) {
defer f.Close()
scanner := bufio.NewScanner(f)
for scanner.Scan() {
key, val, found := utils.Cut(scanner.Text(), " ")
key, val, found := strings.Cut(scanner.Text(), " ")
if found {
set_color_in_color_map(strings.ToLower(key), strings.ToLower(strings.TrimSpace(val)), ans, true, true)
}

View File

@@ -6,8 +6,6 @@ import (
"fmt"
"strconv"
"strings"
"kitty/tools/utils"
)
func parse_set_spacing(args []string) (map[string]any, error) {
@@ -24,7 +22,7 @@ func parse_set_spacing(args []string) (map[string]any, error) {
mapper[q+"-bottom"] = []string{q + "bottom"}
}
for _, arg := range args {
k, v, found := utils.Cut(arg, "=")
k, v, found := strings.Cut(arg, "=")
if !found {
return nil, fmt.Errorf("%s is not a valid setting", arg)
}

View File

@@ -5,8 +5,6 @@ package at
import (
"fmt"
"strings"
"kitty/tools/utils"
)
var valid_color_names = map[string]bool{"active_fg": true, "active_bg": true, "inactive_fg": true, "inactive_bg": true}
@@ -14,7 +12,7 @@ var valid_color_names = map[string]bool{"active_fg": true, "active_bg": true, "i
func parse_tab_colors(args []string) (map[string]any, error) {
ans := make(map[string]any, len(args))
for _, arg := range args {
key, val, found := utils.Cut(strings.ToLower(arg), "=")
key, val, found := strings.Cut(strings.ToLower(arg), "=")
if !found {
return nil, fmt.Errorf("%s is not a valid setting", arg)
}