feat: add shell login option (#75)

Closes #72
This commit is contained in:
Paolo Ricciuti
2026-07-30 22:45:23 +07:00
committed by GitHub
parent 37182f7212
commit 2573ad73b4
10 changed files with 103 additions and 12 deletions
+1
View File
@@ -35,6 +35,7 @@ func (d Duration) MarshalText() ([]byte, error) {
type CoreConfig struct {
Version int `toml:"version"`
Shell string `toml:"shell"`
ShellLogin bool `toml:"shell-login"`
Mode string `toml:"mode"`
Debug bool `toml:"debug"`
ExpandAlias bool `toml:"expand-alias"`
+24 -4
View File
@@ -12,6 +12,9 @@ func TestDefaultConfigAndState(t *testing.T) {
if cfg.Core.Version != 1 {
t.Errorf("expected version 1, got %d", cfg.Core.Version)
}
if cfg.Core.ShellLogin {
t.Errorf("expected login shell to be disabled by default")
}
if cfg.UI.MaxSuggestions != 100 {
t.Errorf("expected suggestions 100, got %d", cfg.UI.MaxSuggestions)
}
@@ -90,14 +93,23 @@ func TestValidationAndEnvironmentOverrides(t *testing.T) {
}
defer os.RemoveAll(tmpDir)
// UserConfigDir follows HOME on macOS and XDG_CONFIG_HOME on Unix.
// Override both so the test cannot read or write the user's real config.
t.Setenv("HOME", tmpDir)
t.Setenv("XDG_CONFIG_HOME", tmpDir)
configDir := filepath.Join(tmpDir, "iris")
configPath, err := ConfigPath()
if err != nil {
t.Fatalf("failed to get config path: %v", err)
}
configDir := filepath.Dir(configPath)
if mkErr := os.MkdirAll(configDir, 0755); mkErr != nil {
t.Fatalf("failed to create config dir: %v", mkErr)
}
configPath := filepath.Join(configDir, "config.toml")
tomlContent := `
[core]
shell-login = true
[ai]
enabled = true
provider = "groq"
@@ -132,6 +144,9 @@ model = "qwen-2.5-coder-32b"
if !cfg.Core.Debug {
t.Errorf("expected debug to be true")
}
if !cfg.Core.ShellLogin {
t.Errorf("expected login shell to be enabled from TOML")
}
if cfg.Core.Shell != "fish" {
t.Errorf("expected shell fish, got %q", cfg.Core.Shell)
}
@@ -178,6 +193,9 @@ func TestLoadSave(t *testing.T) {
}
defer os.RemoveAll(tmpDir)
// UserConfigDir follows HOME on macOS and XDG_CONFIG_HOME on Unix.
// Override both so the test cannot read or write the user's real config.
t.Setenv("HOME", tmpDir)
t.Setenv("XDG_CONFIG_HOME", tmpDir)
cfg, err := Load()
@@ -186,6 +204,7 @@ func TestLoadSave(t *testing.T) {
}
cfg.Core.Shell = "zsh"
cfg.Core.ShellLogin = true
cfg.UI.MaxHeight = 20
err = Save(cfg)
@@ -201,6 +220,9 @@ func TestLoadSave(t *testing.T) {
if loaded.Core.Shell != "zsh" {
t.Errorf("expected loaded shell to be zsh, got %q", loaded.Core.Shell)
}
if !loaded.Core.ShellLogin {
t.Errorf("expected loaded login shell setting to be true")
}
if loaded.UI.MaxHeight != 20 {
t.Errorf("expected loaded height to be 20, got %d", loaded.UI.MaxHeight)
}
@@ -250,5 +272,3 @@ func TestMigration(t *testing.T) {
t.Errorf("expected backup file update_state.json.bak to exist")
}
}
+1
View File
@@ -7,6 +7,7 @@ func DefaultConfig() *Config {
Core: CoreConfig{
Version: 1,
Shell: "",
ShellLogin: false,
Mode: "last",
Debug: false,
ExpandAlias: true,