File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed
Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change 88using ZLogger ;
99
1010
11- ConsoleApp . Run ( args , ( string name ) => Console . WriteLine ( $ "Hello { name } ") ) ;
11+
12+ var app = ConsoleApp . Create ( args ) ;
13+
14+ app . AddSubCommands < FooBarBaz > ( ) ;
15+
16+ //app.AddAllCommandType();
17+
18+ app . Run ( ) ;
1219
1320//args = new[] { "--message", "tako" };
1421
22+ public class FooBarBaz : ConsoleAppBase
23+ {
24+ public void EchoNano ( string msg , int repeat = 3 )
25+ {
26+ for ( var i = 0 ; i < repeat ; i ++ )
27+ {
28+ Console . WriteLine ( msg ) ;
29+ }
30+ }
31+
32+ public void Sum ( [ Option ( 0 ) ] int x , [ Option ( 1 ) ] int y )
33+ {
34+ Console . WriteLine ( ( x + y ) . ToString ( ) ) ;
35+ }
36+ }
1537
1638
1739//static int Hello([Option("m")]string message, [Option("e")] bool end, [Option("r")] int repeat = 3)
Original file line number Diff line number Diff line change @@ -145,7 +145,7 @@ public ConsoleApp AddSubCommands<T>()
145145 {
146146 var methods = typeof ( T ) . GetMethods ( BindingFlags . Public | BindingFlags . Instance | BindingFlags . DeclaredOnly ) ;
147147
148- var rootName = typeof ( T ) . GetCustomAttribute < CommandAttribute > ( ) ? . CommandNames [ 0 ] ?? typeof ( T ) . Name ;
148+ var rootName = typeof ( T ) . GetCustomAttribute < CommandAttribute > ( ) ? . CommandNames [ 0 ] ?? options . NameConverter ( typeof ( T ) . Name ) ;
149149
150150 foreach ( var method in methods )
151151 {
You can’t perform that action at this time.
0 commit comments