Skip to content

Commit 620c5a5

Browse files
committed
Renamed to OutputType
1 parent b5ed438 commit 620c5a5

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

BooleanExpressionParser/Program.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace BooleanExpressionParser;
66

77

8-
enum Output
8+
enum OutputType
99
{
1010
Display,
1111
Basic
@@ -24,7 +24,7 @@ private static void Main(string[] args)
2424
var expressionsArgument = new Argument<string[]>("expression(s)", description: "The boolean expression(s) to evaluate.");
2525

2626
// Shared options
27-
var outputOption = new Option<Output>(new[] { "--output", "-o" }, description: "The output format to use.");
27+
var outputTypeOption = new Option<OutputType>(new[] { "--output", "--output-type", "-o" }, description: "The output type to use.");
2828

2929
// Table command
3030
// Takes in a list of expressions, and prints out the truth table for each one.
@@ -36,7 +36,7 @@ private static void Main(string[] args)
3636

3737
var tableCommand = new Command("table", description: "Prints the truth table of a boolean expression(s). If none are provided, the user will be prompted to enter them.")
3838
{
39-
outputOption,
39+
outputTypeOption,
4040
trueOption,
4141
falseOption,
4242
colourModeOption,
@@ -45,25 +45,25 @@ private static void Main(string[] args)
4545
expressionsArgument
4646
};
4747

48-
tableCommand.SetHandler(TableHandler, outputOption, trueOption, falseOption, colourModeOption, trueColourOption, falseColourOption, expressionsArgument);
48+
tableCommand.SetHandler(TableHandler, outputTypeOption, trueOption, falseOption, colourModeOption, trueColourOption, falseColourOption, expressionsArgument);
4949
rootCommand.AddCommand(tableCommand);
5050

5151
// Convert command
5252
// Takes in a list of expressions, and converts them to prefix notation.
5353
var convertCommand = new Command("convert", description: "Converts a boolean expression(s) to prefix notation. If none are provided, the user will be prompted to enter them.")
5454
{
55-
outputOption,
55+
outputTypeOption,
5656
expressionsArgument
5757
};
5858

59-
convertCommand.SetHandler(ConvertHandler, outputOption, expressionsArgument);
59+
convertCommand.SetHandler(ConvertHandler, outputTypeOption, expressionsArgument);
6060
rootCommand.AddCommand(convertCommand);
6161

6262
rootCommand.Invoke(args);
6363
}
6464

6565

66-
private static void TableHandler(Output output, string @true, string @false, ColourMode colourMode, string trueColour, string falseColour, string[] args)
66+
private static void TableHandler(OutputType outputType, string @true, string @false, ColourMode colourMode, string trueColour, string falseColour, string[] args)
6767
{
6868
var expressions = ParseExpressions(args);
6969

@@ -115,9 +115,10 @@ private static void TableHandler(Output output, string @true, string @false, Col
115115
}
116116
}
117117

118-
private static void ConvertHandler(Output output, string[] args)
118+
private static void ConvertHandler(OutputType outputType, string[] args)
119119
{
120120
var expressions = ParseExpressions(args);
121+
var formatter = new Formatter();
121122

122123
foreach (var expression in expressions)
123124
{
@@ -127,7 +128,7 @@ private static void ConvertHandler(Output output, string[] args)
127128
var parser = new Parser();
128129
var prefixTokens = parser.InfixToPrefix(infixTokens);
129130

130-
AnsiConsole.MarkupLine($"{expression.Expression} -> [bold]{string.Join(" ", prefixTokens)}[/]");
131+
AnsiConsole.MarkupLine($"{expression.Expression} -> [bold]{formatter.FormatTokens(prefixTokens)}[/]");
131132
}
132133
}
133134

0 commit comments

Comments
 (0)