File tree Expand file tree Collapse file tree 6 files changed +18
-18
lines changed
CodeOfChaos.CliArgsParser.Contracts
CodeOfChaos.CliArgsParser
Sample.CodeOfChaos.CliArgsParser
Tools.CodeOfChaos.CliArgsParser
tests/Tests.CodeOfChaos.CliArgsParser Expand file tree Collapse file tree 6 files changed +18
-18
lines changed Original file line number Diff line number Diff line change @@ -9,10 +9,10 @@ namespace CodeOfChaos.CliArgsParser;
99// Code
1010// ---------------------------------------------------------------------------------------------------------------------
1111public interface ICliParserBuilder {
12- ICliParserBuilder AddServices ( IServiceProvider provider ) ;
13- ICliParserBuilder AddServices ( Func < IServiceProvider > provider ) ;
14- ICliParserBuilder AddCommandsFromAssembly < TEntrypoint > ( ) ;
15- ICliParserBuilder AddCommandsFromAssembly ( Assembly assembly ) ;
12+ ICliParserBuilder WithServiceProvider ( IServiceProvider provider ) ;
13+ ICliParserBuilder WithServiceProvider ( Func < IServiceProvider > provider ) ;
14+ ICliParserBuilder AddFromAssembly < TEntrypoint > ( ) ;
15+ ICliParserBuilder AddFromAssembly ( Assembly assembly ) ;
1616
1717 ICliParser Build ( ) ;
1818}
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ public partial class CliParser : ICliParser {
1818 // Methods
1919 // -----------------------------------------------------------------------------------------------------------------
2020 internal CliParser ( ) { }
21- public static CliParserBuilder FromBuilder ( ) {
21+ public static CliParserBuilder CreateBuilder ( ) {
2222 return new CliParserBuilder ( ) ;
2323 }
2424
Original file line number Diff line number Diff line change @@ -19,19 +19,19 @@ public partial class CliParserBuilder : ICliParserBuilder {
1919 // -----------------------------------------------------------------------------------------------------------------
2020 // Methods
2121 // -----------------------------------------------------------------------------------------------------------------
22- public ICliParserBuilder AddServices ( IServiceProvider provider ) {
22+ public ICliParserBuilder WithServiceProvider ( IServiceProvider provider ) {
2323 ServiceProvider = ( ) => provider ;
2424 return this ;
2525 }
2626
27- public ICliParserBuilder AddServices ( Func < IServiceProvider > provider ) {
27+ public ICliParserBuilder WithServiceProvider ( Func < IServiceProvider > provider ) {
2828 ServiceProvider = provider ;
2929 return this ;
3030 }
3131
32- public ICliParserBuilder AddCommandsFromAssembly < TEntrypoint > ( ) => AddCommandsFromAssembly ( typeof ( TEntrypoint ) . Assembly ) ;
32+ public ICliParserBuilder AddFromAssembly < TEntrypoint > ( ) => AddFromAssembly ( typeof ( TEntrypoint ) . Assembly ) ;
3333
34- public ICliParserBuilder AddCommandsFromAssembly ( Assembly assembly ) {
34+ public ICliParserBuilder AddFromAssembly ( Assembly assembly ) {
3535 Type [ ] types = assembly . GetTypes ( ) ;
3636 Type ? staticDictionaryType = types . FirstOrDefault ( t => FindCommandDictionary . IsMatch ( t . Name ) && t . IsClass ) ;
3737 var commandsDictionary = staticDictionaryType ? . GetField ( "Commands" ) ? . GetValue ( null ) as Dictionary < string , Type > ;
Original file line number Diff line number Diff line change @@ -10,8 +10,8 @@ namespace Sample.CodeOfChaos.CliArgsParser;
1010// ---------------------------------------------------------------------------------------------------------------------
1111public static class Program {
1212 public static async Task Main ( string [ ] args ) {
13- ICliParser parser = CliParser . FromBuilder ( )
14- . AddCommandsFromAssembly < TestCommand > ( )
13+ ICliParser parser = CliParser . CreateBuilder ( )
14+ . AddFromAssembly < TestCommand > ( )
1515 . Build ( ) ;
1616
1717 await parser . ExecuteAsync ( args ) ;
Original file line number Diff line number Diff line change @@ -12,8 +12,8 @@ public static class Program {
1212 public static async Task Main ( string [ ] args ) {
1313 // Register & Build the parser
1414 // Don't forget to add the current assembly if you built more tools for the current project
15- ICliParser parser = CliParser . FromBuilder ( )
16- . AddCommandsFromAssembly < IAssemblyEntry > ( )
15+ ICliParser parser = CliParser . CreateBuilder ( )
16+ . AddFromAssembly < IAssemblyEntry > ( )
1717 . Build ( ) ;
1818
1919 // We are doing this here because else the launchSettings.json file becomes a humongous issue to deal with.
Original file line number Diff line number Diff line change @@ -15,8 +15,8 @@ public class CliParserTests {
1515 public async Task ExecuteAsync_Test ( ) {
1616 // Arrange
1717 const string input = "test-command --test-required-string=\" something\" " ;
18- ICliParser parser = CliParser . FromBuilder ( )
19- . AddCommandsFromAssembly ( typeof ( CliParserTests ) . Assembly )
18+ ICliParser parser = CliParser . CreateBuilder ( )
19+ . AddFromAssembly ( typeof ( CliParserTests ) . Assembly )
2020 . Build ( ) ;
2121
2222 // Act
@@ -34,9 +34,9 @@ public async Task ExecuteAsync_TestWithServices() {
3434 services . AddSingleton < IService , Service > ( ) ;
3535 ServiceProvider provider = services . BuildServiceProvider ( ) ;
3636
37- ICliParser parser = CliParser . FromBuilder ( )
38- . AddServices ( provider )
39- . AddCommandsFromAssembly ( typeof ( CliParserTests ) . Assembly )
37+ ICliParser parser = CliParser . CreateBuilder ( )
38+ . WithServiceProvider ( provider )
39+ . AddFromAssembly ( typeof ( CliParserTests ) . Assembly )
4040 . Build ( ) ;
4141
4242 // Act
You can’t perform that action at this time.
0 commit comments