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 8
8
using ZLogger ;
9
9
10
10
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 ( ) ;
12
19
13
20
//args = new[] { "--message", "tako" };
14
21
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
+ }
15
37
16
38
17
39
//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>()
145
145
{
146
146
var methods = typeof ( T ) . GetMethods ( BindingFlags . Public | BindingFlags . Instance | BindingFlags . DeclaredOnly ) ;
147
147
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 ) ;
149
149
150
150
foreach ( var method in methods )
151
151
{
You can’t perform that action at this time.
0 commit comments