55namespace 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