Skip to content

Commit bc82148

Browse files
committed
Fix print command
1 parent 7df9fff commit bc82148

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/SeqCli/Cli/Commands/PrintCommand.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,13 @@ class PrintCommand : Command
3434
{
3535
readonly FileInputFeature _fileInputFeature;
3636
readonly InvalidDataHandlingFeature _invalidDataHandlingFeature;
37+
readonly StoragePathFeature _storage;
3738

3839
string? _filter, _template = OutputFormat.DefaultOutputTemplate;
39-
bool _noColor, _forceColor;
40+
bool? _noColor, _forceColor;
4041

41-
public PrintCommand(SeqCliOutputConfig seqCliOutputConfig)
42+
public PrintCommand()
4243
{
43-
if (seqCliOutputConfig == null) throw new ArgumentNullException(nameof(seqCliOutputConfig));
44-
_noColor = seqCliOutputConfig.DisableColor;
45-
_forceColor = seqCliOutputConfig.ForceColor;
46-
4744
_fileInputFeature = Enable(new FileInputFeature("CLEF file to read", allowMultiple: true));
4845

4946
Options.Add("f=|filter=",
@@ -56,20 +53,24 @@ public PrintCommand(SeqCliOutputConfig seqCliOutputConfig)
5653

5754
_invalidDataHandlingFeature = Enable<InvalidDataHandlingFeature>();
5855

56+
// These should be ported to use `OutputFormatFeature`.
5957
Options.Add("no-color", "Don't colorize text output", _ => _noColor = true);
60-
6158
Options.Add("force-color",
6259
"Force redirected output to have ANSI color (unless `--no-color` is also specified)",
6360
_ => _forceColor = true);
61+
62+
_storage = Enable<StoragePathFeature>();
6463
}
6564

6665
protected override async Task<int> Run()
6766
{
67+
var config = RuntimeConfigurationLoader.Load(_storage);
68+
6869
var applyThemeToRedirectedOutput
69-
= !_noColor && _forceColor;
70+
= !(_noColor ?? config.Output.DisableColor) && (_forceColor ?? config.Output.ForceColor);
7071

7172
var theme
72-
= _noColor ? ConsoleTheme.None
73+
= _noColor ?? config.Output.DisableColor ? ConsoleTheme.None
7374
: applyThemeToRedirectedOutput ? OutputFormat.DefaultAnsiTheme
7475
: OutputFormat.DefaultTheme;
7576

0 commit comments

Comments
 (0)