Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
This commit is contained in:
Hadi
2026-05-12 19:12:29 +02:00
commit e8e64eff12
101 changed files with 10081 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
package config
type Colors struct {
Base00 string `mapstructure:"base00"`
Base01 string `mapstructure:"base01"`
Base02 string `mapstructure:"base02"`
Base03 string `mapstructure:"base03"`
Base04 string `mapstructure:"base04"`
Base05 string `mapstructure:"base05"`
Base06 string `mapstructure:"base06"`
Base07 string `mapstructure:"base07"`
Base08 string `mapstructure:"base08"`
Base09 string `mapstructure:"base09"`
Base0A string `mapstructure:"base0a"`
Base0B string `mapstructure:"base0b"`
Base0C string `mapstructure:"base0c"`
Base0D string `mapstructure:"base0d"`
Base0E string `mapstructure:"base0e"`
Base0F string `mapstructure:"base0f"`
}
+101
View File
@@ -0,0 +1,101 @@
package config
import (
_ "embed"
"fmt"
"os"
"path/filepath"
"strings"
"github.com/spf13/viper"
"gopkg.in/yaml.v3"
)
//go:embed default_config.yaml
var defaultConfig []byte
type Config struct {
Version string `mapstructure:"-"`
App struct {
Host string `mapstructure:"host"`
Port int `mapstructure:"port"`
CertDir string `mapstructure:"cert_dir"`
ProjectDir string `mapstructure:"project_dir"`
PluginsDir string `mapstructure:"plugins_dir"`
} `mapstructure:"app"`
TUI struct {
Colors Colors `mapstructure:"colors"`
UseNerdfontIcons bool `mapstructure:"use_nerdfont_icons"`
DefaultSidebarState string `mapstructure:"default_sidebar_state"`
PrettyPrintBody bool `mapstructure:"pretty_print_body"`
} `mapstructure:"tui"`
Intercept struct {
DefaultAutoForward bool `mapstructure:"default_auto_forward"`
DefaultCaptureResponse bool `mapstructure:"default_capture_response"`
} `mapstructure:"intercept"`
Replay struct {
SwitchToPageOnSend bool `mapstructure:"switch_to_page_on_send"`
} `mapstructure:"replay"`
History struct {
SkipDuplicates bool `mapstructure:"skip_duplicates"`
} `mapstructure:"history"`
Keybindings Keybindings `mapstructure:"keybindings"`
}
var Global *Config
func Load(path string) error {
var defaults map[string]any
if err := yaml.Unmarshal(defaultConfig, &defaults); err != nil {
return fmt.Errorf("default config: %w", err)
}
for k, v := range flatten("", defaults) {
viper.SetDefault(k, v)
}
viper.SetConfigType("yaml")
viper.SetConfigFile(path)
if err := viper.ReadInConfig(); err != nil {
if !os.IsNotExist(err) {
return err
}
}
Global = &Config{}
return viper.Unmarshal(Global)
}
func ExpandPath(p string) string {
if strings.HasPrefix(p, "~/") {
home, err := os.UserHomeDir()
if err != nil {
return p
}
return filepath.Join(home, p[2:])
}
return p
}
func flatten(prefix string, m map[string]any) map[string]any {
out := make(map[string]any)
for k, v := range m {
key := k
if prefix != "" {
key = prefix + "." + k
}
if nested, ok := v.(map[string]any); ok {
for nk, nv := range flatten(key, nested) {
out[nk] = nv
}
} else {
out[key] = v
}
}
return out
}
+96
View File
@@ -0,0 +1,96 @@
app:
host: 127.0.0.1
port: 8080
cert_dir: ~/.local/share/spilltea
project_dir: ~/.local/share/spilltea
plugins_dir: ~/.config/spilltea/plugins
intercept:
default_auto_forward: false
default_capture_response: false
replay:
switch_to_page_on_send: false
history:
skip_duplicates: false # if true, skip saving entries with the same method, host, path and body
tui:
use_nerdfont_icons: true
default_sidebar_state: "expanded" # hidden, collapsed, expanded
pretty_print_body: true # auto-indent JSON and HTML response bodies
colors:
base00: "110F12" # Default Background
base01: "1C1920" # Lighter Background (status bars, line numbers)
base02: "1D1A26" # Selection Background
base03: "514D63" # Comments, Invisibles, faint text
base04: "8E8AA0" # Dark Foreground (status bars)
base05: "C2BED6" # Default Foreground, Caret, Delimiters
base06: "D8D5EA" # Light Foreground (rarely used)
base07: "EAE7F7" # Light Background (rarely used)
base08: "E07080" # Red: errors, diff deleted
base09: "D49070" # Orange: integers, constants, warnings
base0a: "C4B060" # Yellow: classes, search highlight
base0b: "80B880" # Green: strings, diff inserted, success
base0c: "70B8C0" # Cyan: support, regex, escape chars
base0d: "9E97F8" # Blue/Accent: functions, headings, primary
base0e: "C090E8" # Purple: keywords, storage
base0f: "D080A0" # Pink: deprecated, embedded language tags
keybindings:
global:
quit: "q,ctrl+c"
open_logs: "ctrl+g"
toggle_sidebar: "ctrl+b"
help: "?"
up: "up,k"
down: "down,j"
left: "left,h"
right: "right,l"
cycle_focus: "tab"
copy_request: "ctrl+y"
send_to_replay: "ctrl+r"
scroll_up: "pgup"
scroll_down: "pgdown"
send_to_diff: "ctrl+d"
intercept:
forward: "f"
forward_all: "F"
drop: "d"
drop_all: "D"
auto_forward: "a"
capture_response: "r"
undo_edits: "ctrl+z"
edit: "e,enter"
edit_external: "E"
history:
delete_entry: "x"
delete_all: "X"
sql_query: ":"
filter: "/"
home:
open: "enter,l"
delete: "x"
filter: "/"
replay:
send: "enter,s"
edit: "e"
edit_external: "E"
undo_edits: "R"
delete_entry: "x"
delete_all: "X"
diff:
clear: "c"
findings:
dismiss: "x"
plugins:
toggle: "space"
edit_config: "e,enter"
filter: "/"
+77
View File
@@ -0,0 +1,77 @@
package config
type GlobalKeys struct {
Quit string `mapstructure:"quit"`
OpenLogs string `mapstructure:"open_logs"`
ToggleSidebar string `mapstructure:"toggle_sidebar"`
Help string `mapstructure:"help"`
Up string `mapstructure:"up"`
Down string `mapstructure:"down"`
Left string `mapstructure:"left"`
Right string `mapstructure:"right"`
CycleFocus string `mapstructure:"cycle_focus"`
CopyRequest string `mapstructure:"copy_request"`
SendToReplay string `mapstructure:"send_to_replay"`
ScrollUp string `mapstructure:"scroll_up"`
ScrollDown string `mapstructure:"scroll_down"`
SendToDiff string `mapstructure:"send_to_diff"`
}
type InterceptKeys struct {
Forward string `mapstructure:"forward"`
ForwardAll string `mapstructure:"forward_all"`
Drop string `mapstructure:"drop"`
DropAll string `mapstructure:"drop_all"`
AutoForward string `mapstructure:"auto_forward"`
CaptureResponse string `mapstructure:"capture_response"`
UndoEdits string `mapstructure:"undo_edits"`
Edit string `mapstructure:"edit"`
EditExternal string `mapstructure:"edit_external"`
}
type HistoryKeys struct {
DeleteEntry string `mapstructure:"delete_entry"`
DeleteAll string `mapstructure:"delete_all"`
Filter string `mapstructure:"filter"`
SqlQuery string `mapstructure:"sql_query"`
}
type HomeKeys struct {
Open string `mapstructure:"open"`
Delete string `mapstructure:"delete"`
Filter string `mapstructure:"filter"`
}
type ReplayKeys struct {
Send string `mapstructure:"send"`
Edit string `mapstructure:"edit"`
EditExt string `mapstructure:"edit_external"`
UndoEdits string `mapstructure:"undo_edits"`
Delete string `mapstructure:"delete_entry"`
DeleteAll string `mapstructure:"delete_all"`
}
type DiffKeys struct {
Clear string `mapstructure:"clear"`
}
type FindingsKeys struct {
Dismiss string `mapstructure:"dismiss"`
}
type PluginsKeys struct {
Toggle string `mapstructure:"toggle"`
EditConfig string `mapstructure:"edit_config"`
Filter string `mapstructure:"filter"`
}
type Keybindings struct {
Global GlobalKeys `mapstructure:"global"`
Intercept InterceptKeys `mapstructure:"intercept"`
Home HomeKeys `mapstructure:"home"`
History HistoryKeys `mapstructure:"history"`
Replay ReplayKeys `mapstructure:"replay"`
Diff DiffKeys `mapstructure:"diff"`
Findings FindingsKeys `mapstructure:"findings"`
Plugins PluginsKeys `mapstructure:"plugins"`
}