@@ -70,7 +70,9 @@ private static int Wain(string[] args)
70
70
71
71
app . HelpOption ( "-? | -h | --help" ) ;
72
72
73
- app . VersionOption ( "-v | --version" , GetVersionInfo ) ;
73
+ app . VersionOption ( "-v | --version" , GetVersion ( ) ) ;
74
+
75
+ var infoOption = app . Option ( "--info" , "Displays environmental information" , CommandOptionType . NoValue ) ;
74
76
75
77
app . Command ( "eval" , c =>
76
78
{
@@ -127,6 +129,13 @@ private static int Wain(string[] args)
127
129
app . OnExecute ( async ( ) =>
128
130
{
129
131
int exitCode = 0 ;
132
+
133
+ if ( infoOption . HasValue ( ) )
134
+ {
135
+ Console . Write ( GetEnvironmentInfo ( ) ) ;
136
+ return 0 ;
137
+ }
138
+
130
139
if ( ! string . IsNullOrWhiteSpace ( file . Value ) )
131
140
{
132
141
var optimizationLevel = OptimizationLevel . Debug ;
@@ -207,18 +216,21 @@ private static Task<int> Run(bool debugMode, ScriptContext context)
207
216
return runner . Execute < int > ( context ) ;
208
217
}
209
218
210
- private static string GetVersionInfo ( )
219
+ private static string GetEnvironmentInfo ( )
211
220
{
212
- StringBuilder sb = new StringBuilder ( ) ;
213
- var versionAttribute = typeof ( Program ) . GetTypeInfo ( ) . Assembly . GetCustomAttributes < AssemblyInformationalVersionAttribute > ( ) . SingleOrDefault ( ) ;
214
- sb . AppendLine ( $ "Version : { versionAttribute ? . InformationalVersion } ") ;
221
+ StringBuilder sb = new StringBuilder ( ) ;
222
+ sb . AppendLine ( $ "Version : { GetVersion ( ) } ") ;
215
223
sb . AppendLine ( $ "Install location : { ScriptEnvironment . Default . InstallLocation } ") ;
216
224
sb . AppendLine ( $ "Target framework : { ScriptEnvironment . Default . TargetFramework } ") ;
217
225
sb . AppendLine ( $ "Platform identifier : { ScriptEnvironment . Default . PlatformIdentifier } ") ;
218
226
sb . AppendLine ( $ "Runtime identifier : { ScriptEnvironment . Default . RuntimeIdentifier } ") ;
219
- return sb . ToString ( ) ;
227
+ return sb . ToString ( ) ;
228
+ }
220
229
221
-
230
+ private static string GetVersion ( )
231
+ {
232
+ var versionAttribute = typeof ( Program ) . GetTypeInfo ( ) . Assembly . GetCustomAttributes < AssemblyInformationalVersionAttribute > ( ) . SingleOrDefault ( ) ;
233
+ return versionAttribute ? . InformationalVersion ;
222
234
}
223
235
224
236
private static ScriptCompiler GetScriptCompiler ( bool debugMode )
0 commit comments