mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
27e988c484
- Implement POSIX-specific gateway process management in gateway_posix.go - Implement Windows-specific gateway process management in gateway_windows.go - Create a menu system in menu.go for user interaction - Develop model management functionality in model.go, including adding, deleting, and testing models - Introduce a style configuration in style.go for consistent UI appearance - Set up the main application entry point in main.go - Update go.mod and go.sum to include necessary dependencies for tcell and tview
50 lines
863 B
Go
50 lines
863 B
Go
package configstore
|
|
|
|
import (
|
|
"errors"
|
|
"os"
|
|
"path/filepath"
|
|
|
|
picoclawconfig "github.com/sipeed/picoclaw/pkg/config"
|
|
)
|
|
|
|
const (
|
|
configDirName = ".picoclaw"
|
|
configFileName = "config.json"
|
|
)
|
|
|
|
func ConfigPath() (string, error) {
|
|
dir, err := ConfigDir()
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return filepath.Join(dir, configFileName), nil
|
|
}
|
|
|
|
func ConfigDir() (string, error) {
|
|
home, err := os.UserHomeDir()
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return filepath.Join(home, configDirName), nil
|
|
}
|
|
|
|
func Load() (*picoclawconfig.Config, error) {
|
|
path, err := ConfigPath()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return picoclawconfig.LoadConfig(path)
|
|
}
|
|
|
|
func Save(cfg *picoclawconfig.Config) error {
|
|
if cfg == nil {
|
|
return errors.New("config is nil")
|
|
}
|
|
path, err := ConfigPath()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return picoclawconfig.SaveConfig(path, cfg)
|
|
}
|