Skip to content

Commit 7a747ba

Browse files
committed
accessible implies no-color
1 parent 9c26894 commit 7a747ba

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

cmd/root.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,11 @@ func InitConfig(ctx context.Context, clients *shared.ClientFactory, rootCmd *cob
247247
clients.Config.SystemConfig.SetCustomConfigDirPath(clients.Config.ConfigDirFlag)
248248
}
249249

250+
// Accessible mode implies no-color
251+
if clients.Config.Accessible {
252+
clients.Config.NoColor = true
253+
}
254+
250255
// Init color and formatting
251256
style.ToggleStyles(clients.IO.IsTTY() && !clients.Config.NoColor)
252257
style.ToggleSpinner(clients.IO.IsTTY() && !clients.Config.NoColor && !clients.Config.DebugEnabled)

cmd/root_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"strings"
2222
"testing"
2323

24+
"github.com/slackapi/slack-cli/internal/config"
2425
"github.com/slackapi/slack-cli/internal/iostreams"
2526
"github.com/slackapi/slack-cli/internal/shared"
2627
"github.com/slackapi/slack-cli/internal/slackcontext"
@@ -194,6 +195,15 @@ func TestVersionFlags(t *testing.T) {
194195
assert.True(t, testutil.ContainsSemVer(output), `-v should output the version number but yielded "%s"`, output)
195196
}
196197

198+
func Test_AccessibleImpliesNoColor(t *testing.T) {
199+
cfg := &config.Config{Accessible: true}
200+
// Simulate the logic from PersistentPreRunE
201+
if cfg.Accessible {
202+
cfg.NoColor = true
203+
}
204+
assert.True(t, cfg.NoColor, "--accessible should imply --no-color")
205+
}
206+
197207
func Test_NewSuggestion(t *testing.T) {
198208
ctx := slackcontext.MockContext(t.Context())
199209

0 commit comments

Comments
 (0)