22using System . Threading . Tasks ;
33using System . Linq ;
44using System . Reflection ;
5+ using System . Runtime . InteropServices ;
56
67using System . CommandLine ;
78
8- using RSML ;
99using RSML . Parser ;
10- using System . Runtime . InteropServices ;
1110using RSML . Exceptions ;
1211
1312
@@ -108,13 +107,19 @@ static async Task Main(string[] args)
108107 description : "Custom RID to check against" ,
109108 getDefaultValue : ( ) => null
110109 ) ;
110+ var expandAnyOption = new Option < bool > (
111+ aliases : [ "--expand-any" , "-x" ] ,
112+ description : "Expands the any RID" ,
113+ getDefaultValue : ( ) => false
114+ ) ;
111115
112116 evaluateCommand . AddOption ( printOnlyPrimaryOption ) ;
113117 evaluateCommand . AddOption ( customRidOption ) ;
118+ evaluateCommand . AddOption ( expandAnyOption ) ;
114119 evaluateCommand . AddOption ( fallbackForErrorOption ) ;
115120 evaluateCommand . AddOption ( fallbackForNullOption ) ;
116121
117- evaluateCommand . SetHandler ( void ( primaryOnly , nullFallback , errorFallback , customRid ) =>
122+ evaluateCommand . SetHandler ( void ( primaryOnly , nullFallback , errorFallback , customRid , expandAny ) =>
118123 {
119124
120125 string ? currentInState = Console . In . ReadToEnd ( ) ;
@@ -149,9 +154,26 @@ static async Task Main(string[] args)
149154 try
150155 {
151156
152- Console . WriteLine ( customRid is null
153- ? document . EvaluateDocument ( ) ?? ( ( nullFallback ?? "" ) == "" ? "[WARNING] No match was found." : nullFallback ! )
154- : document . EvaluateDocument ( customRid , null ) ?? ( ( nullFallback ?? "" ) == "" ? "[WARNING] No match was found." : nullFallback ! ) ) ;
157+ if ( customRid is not null )
158+ {
159+
160+ Console . WriteLine (
161+ ( document . EvaluateDocument ( customRid , expandAny ) ) ??
162+ ( ( nullFallback is null )
163+ ? "[WARNING] No match was found."
164+ : nullFallback ) ) ;
165+
166+ }
167+ else
168+ {
169+
170+ Console . WriteLine (
171+ ( document . EvaluateDocument ( expandAny ) ) ??
172+ ( ( nullFallback is null )
173+ ? "[WARNING] No match was found."
174+ : nullFallback ) ) ;
175+
176+ }
155177
156178 }
157179 catch ( RSMLRuntimeException ex )
@@ -164,7 +186,7 @@ static async Task Main(string[] args)
164186
165187 Environment . Exit ( 0 ) ;
166188
167- } , printOnlyPrimaryOption , fallbackForNullOption , fallbackForErrorOption , customRidOption ) ;
189+ } , printOnlyPrimaryOption , fallbackForNullOption , fallbackForErrorOption , customRidOption , expandAnyOption ) ;
168190
169191 evaluateCommand . AddAlias ( "eval" ) ;
170192 evaluateCommand . AddAlias ( "parse" ) ;
@@ -175,7 +197,7 @@ static async Task Main(string[] args)
175197 repoCommand . SetHandler ( void ( ) =>
176198 {
177199
178- Console . WriteLine ( "\0 33[1mVisit the repository at:\0 33[0m \0 33[4mhttps ://github.com/OceanApocalypseStudios/RedSeaMarkupLanguage\0 33[0m " ) ;
200+ Console . WriteLine ( "Visit the repository at: https ://github.com/OceanApocalypseStudios/RedSeaMarkupLanguage" ) ;
179201 Environment . Exit ( 0 ) ;
180202
181203 } ) ;
0 commit comments