@@ -246,9 +246,10 @@ func configSSH() *cobra.Command {
246
246
}
247
247
}
248
248
249
+ color := isTTY (cmd )
249
250
for _ , diffFn := range []func () ([]byte , error ){
250
- func () ([]byte , error ) { return diffBytes (sshConfigFile , configRaw , configModified ) },
251
- func () ([]byte , error ) { return diffBytes (coderConfigFile , coderConfigRaw , buf .Bytes ()) },
251
+ func () ([]byte , error ) { return diffBytes (sshConfigFile , configRaw , configModified , color ) },
252
+ func () ([]byte , error ) { return diffBytes (coderConfigFile , coderConfigRaw , buf .Bytes (), color ) },
252
253
} {
253
254
diff , err := diffFn ()
254
255
if err != nil {
@@ -389,11 +390,11 @@ func currentBinPath(cmd *cobra.Command) (string, error) {
389
390
390
391
// diffBytes takes two byte slices and diffs them as if they were in a
391
392
// file named name.
392
- func diffBytes (name string , b1 , b2 []byte ) ([]byte , error ) {
393
+ //nolint: revive // Color is an option, not a control coupling.
394
+ func diffBytes (name string , b1 , b2 []byte , color bool ) ([]byte , error ) {
393
395
var buf bytes.Buffer
394
396
var opts []write.Option
395
- // TODO(mafredri): Toggle color on/off
396
- if false {
397
+ if color {
397
398
opts = append (opts , write .TerminalColor ())
398
399
}
399
400
err := diff .Text (name , name + ".new" , b1 , b2 , & buf , opts ... )
0 commit comments