@ -1,29 +1,29 @@
using DotWhat.Contracts ;
using Cocona ;
using DotWhat.Contracts ;
using System ;
using System ;
using System.Collections.Generic ;
using System.Collections.Generic ;
using System.Linq ;
using System.Linq ;
using System.Reflection ;
using System.Reflection ;
using System.Threading.Tasks ;
using System.Threading.Tasks ;
using Cocona ;
namespace DotWhat
namespace DotWhat
{
{
class Program
internal class Program
{
{
private static readonly IEnumerable < What > Whats =
private static readonly IEnumerable < What ? > Whats =
Assembly . GetExecutingAssembly ( )
Assembly . GetExecutingAssembly ( )
. GetTypes ( )
. GetTypes ( )
. Where ( type = > type . BaseType = = typeof ( What ) )
. Where ( type = > type . BaseType = = typeof ( What ) )
. Select ( what = > ( What )Activator . CreateInstance ( what ) ) ;
. Select ( what = > ( What ? )Activator . CreateInstance ( what ) ) ;
private static async Task < int > Main ( string [ ] args )
private static async Task < int > Main ( string [ ] args )
{
{
await CoconaLiteApp . RunAsync < Program > ( args ) ;
await CoconaLiteApp . RunAsync < Program > ( args ) .ConfigureAwait ( false ) ;
return 0 ;
return 0 ;
}
}
public async Task StartAsync ( [ Argument ] string name = default )
public void Start ( [ Argument ] string ? name = default )
{
{
if ( string . IsNullOrEmpty ( name ) )
if ( string . IsNullOrEmpty ( name ) )
{
{
@ -32,7 +32,7 @@ namespace DotWhat
return ;
return ;
}
}
var command = Whats . FirstOrDefault ( what = > what .Name . Equals ( name , StringComparison . OrdinalIgnoreCase ) ) ;
var command = Whats . FirstOrDefault ( what = > what ! .Name . Equals ( name , StringComparison . OrdinalIgnoreCase ) ) ;
if ( command is null )
if ( command is null )
{
{
@ -41,10 +41,10 @@ namespace DotWhat
return ;
return ;
}
}
await command . Run Async ( ) ;
command . Run ( ) ;
static void PrintWhats ( )
static void PrintWhats ( )
= > Whats . ToList ( ) . ForEach ( what = > Console . WriteLine ( what .Name . ToLower ( ) ) ) ;
= > Whats . ToList ( ) . ForEach ( what = > Console . WriteLine ( what ! .Name . ToLower ( ) ) ) ;
}
}
}
}
}
}