99
1010
1111
12- var  app  =  ConsoleApp . Create ( ) ; 
12+ // var app = ConsoleApp.Create();
1313
1414
15- args  =  [ "--x" ,  "10" ,  "--y" ,  "20" ,  "-f" ,  "Orange" ,  "-v" ,  "--prefix-output" ,  "takoyakix" ] ; 
15+ // args = ["--x", "10", "--y", "20", "-f", "Orange", "-v", "--prefix-output", "takoyakix"];
1616
1717
18- // Enum.TryParse<Fruit>("", true, 
19- // parse immediately 
18+ ////  Enum.TryParse<Fruit>("", true, 
19+ ////  parse immediately 
2020
2121
22+ //app.ConfigureGlobalOption(x => 
23+ //{ 
24+ //    var verbose = x.AddGlobalOption<bool>($"takoyaki", "", true); 
25+ //    var noColor = x.AddGlobalOption<bool>("--no-color", "Don't colorize output."); 
26+ //    var dryRun = x.AddGlobalOption<bool>("--dry-run"); 
27+ //    var prefixOutput = x.AddRequiredGlobalOption<string>("--prefix-output|-pp|-po", "Prefix output with level."); 
28+ 
29+ //    return new GlobalOptions(verbose, noColor, dryRun, prefixOutput); 
30+ //}); 
31+ 
32+ //app.ConfigureServices(x => 
33+ //{ 
34+ 
35+ //    // new ConsoleAppContext("", 
2236
23- app . ConfigureGlobalOption ( x => 
24- { 
25-     var  verbose  =  x . AddGlobalOption < bool > ( $ "takoyaki",  "" ,  true ) ; 
26-     var  noColor  =  x . AddGlobalOption < bool > ( "--no-color" ,  "Don't colorize output." ) ; 
27-     var  dryRun  =  x . AddGlobalOption < bool > ( "--dry-run" ) ; 
28-     var  prefixOutput  =  x . AddRequiredGlobalOption < string > ( "--prefix-output|-pp|-po" ,  "Prefix output with level." ) ; 
2937
30-     return  ( verbose ,  noColor ,  dryRun ,  prefixOutput ) ; 
31- } ) ; 
3238
33- app . ConfigureServices ( x => 
34- { 
3539
36-     // new ConsoleAppContext("", 
3740
3841
42+ //    // to use command body 
43+ //    //x.AddSingleton<GlobalOptions>(new GlobalOptions(verbose, noColor, dryRun, prefixOutput)); 
3944
45+ //    //// variable for setup other DI 
46+ //    //x.AddLogging(l => 
47+ //    //{ 
48+ //    //    var console = l.AddSimpleConsole(); 
49+ //    //    if (verbose) 
50+ //    //    { 
51+ //    //        console.SetMinimumLevel(LogLevel.Trace); 
52+ //    //    } 
53+ //    //}); 
54+ //}); 
55+ 
56+ //app.Add<Commands>(""); 
57+ 
58+ //app.Run(args); 
59+ 
60+ var  app  =  ConsoleApp . Create ( ) ; 
61+ 
62+ 
63+ app . ConfigureGlobalOptions ( ( ref  builder )  => 
64+ { 
65+     var  verbose =  builder. AddGlobalOption < bool > ( $ "takoyaki",  "" ,  true ) ; 
66+     var  noColor  =  builder . AddGlobalOption < bool > ( "--no-color" ,  "Don't colorize output." ) ; 
67+     var  dryRun  =  builder . AddGlobalOption < bool > ( "--dry-run" ) ; 
68+     var  prefixOutput  =  builder . AddRequiredGlobalOption < string > ( "--prefix-output|-pp|-po" ,  "Prefix output with level." ) ; 
4069
70+     return  new  GlobalOptions ( verbose ,  noColor ,  dryRun ,  prefixOutput ) ; 
71+ } ) ; 
4172
4273
43-     // to use command body 
44-     //x.AddSingleton<GlobalOptions>(new GlobalOptions(verbose, noColor, dryRun, prefixOutput)); 
74+ app . Add ( "" ,  ( int  x ,  int  y ,  ConsoleAppContext  context )  => 
75+ { 
76+     Console . WriteLine ( context . CommandName ) ; 
77+ } ) ; 
4578
46-     //// variable for setup other DI 
47-     //x.AddLogging(l => 
48-     //{ 
49-     //    var console = l.AddSimpleConsole(); 
50-     //    if (verbose) 
51-     //    { 
52-     //        console.SetMinimumLevel(LogLevel.Trace); 
53-     //    } 
54-     //}); 
79+ app . Add ( "tako" ,  ( int  x ,  int  y ,  ConsoleAppContext  context )  => 
80+ { 
81+     Console . WriteLine ( context . CommandName ) ; 
5582} ) ; 
5683
57- app . Add < Commands > ( "" ) ; 
5884
5985app . Run ( args ) ; 
6086
6187
88+ 
89+ 
6290static   T  ParseArgumentEnum < T > ( ref  string [ ]  args ,  int  i ) 
6391    where  T  :  struct ,  Enum 
6492{ 
@@ -83,12 +111,22 @@ static T ParseArgumentEnum<T>(ref string[] args, int i)
83111public  record  GlobalOptions ( bool  Verbose ,  bool  NoColor ,  bool  DryRun ,  string  PrefixOutput ) ; 
84112
85113
114+ internal  delegate  object  TakoyakiX ( FooStruct  builder ) ; 
115+ 
116+ 
86117public  enum  Fruit 
87118{ 
88119    Orange ,  Apple ,  Grape 
89120} 
90121
91122
123+ 
124+ 
125+ public  ref  struct  FooStruct 
126+ { 
127+ } 
128+ 
129+ 
92130public  class  Commands ( GlobalOptions  globalOptions ) 
93131{ 
94132    /// <summary> 
0 commit comments