@@ -17,16 +17,19 @@ public static async Task<int> Main(string[] args)
1717 // ============ COMPUTE COMMAND ============
1818 Command computeCommand = new ( "compute" , "Run computations on FDA studies and generate CSV result reports" ) ;
1919
20- Option < FileInfo > computeConfigOption = new (
20+ Option < FileInfo ? > computeConfigOption = new (
2121 name : "--config" ,
22- description : "Path to JSON configuration file" )
23- { IsRequired = true } ;
22+ description : "Path to JSON configuration file" ) ;
2423 computeConfigOption . AddAlias ( "-c" ) ;
2524
26- Option < DirectoryInfo > computeOutputOption = new (
25+ Option < FileInfo ? > studyPathOption = new (
26+ name : "--study-path" ,
27+ description : "Path to a .sqlite study file (runs all computations)" ) ;
28+ studyPathOption . AddAlias ( "-sp" ) ;
29+
30+ Option < DirectoryInfo ? > computeOutputOption = new (
2731 name : "--output" ,
28- description : "Output directory for generated files" ,
29- getDefaultValue : ( ) => new DirectoryInfo ( Environment . CurrentDirectory ) ) ;
32+ description : "Output directory for generated files" ) ;
3033 computeOutputOption . AddAlias ( "-o" ) ;
3134
3235 Option < string [ ] > computeStudyOption = new (
@@ -36,34 +39,83 @@ public static async Task<int> Main(string[] args)
3639 computeStudyOption . AddAlias ( "-s" ) ;
3740
3841 computeCommand . AddOption ( computeConfigOption ) ;
42+ computeCommand . AddOption ( studyPathOption ) ;
3943 computeCommand . AddOption ( computeOutputOption ) ;
4044 computeCommand . AddOption ( computeStudyOption ) ;
4145
42- computeCommand . SetHandler ( async ( configFile , outputDir , studyFilter ) =>
46+ computeCommand . SetHandler ( async ( configFile , studyPath , outputDir , studyFilter ) =>
4347 {
4448 try
4549 {
4650 Console . WriteLine ( "FDA Testing Utility - Compute" ) ;
4751 Console . WriteLine ( "=============================" ) ;
4852 Console . WriteLine ( ) ;
4953
50- if ( ! configFile . Exists )
54+ if ( configFile != null && studyPath != null )
55+ {
56+ Console . WriteLine ( "Error: Cannot specify both --config and --study-path. Use one or the other." ) ;
57+ return ;
58+ }
59+
60+ if ( configFile == null && studyPath == null )
5161 {
52- Console . WriteLine ( $ "Error: Configuration file not found: { configFile . FullName } ") ;
62+ Console . WriteLine ( "Error: Must specify either --config or --study-path. " ) ;
5363 return ;
5464 }
5565
56- Console . WriteLine ( $ "Loading configuration: { configFile . FullName } " ) ;
57- TestConfiguration config = TestConfiguration . LoadFromFile ( configFile . FullName ) ;
66+ TestConfiguration config ;
67+ string outputPath ;
5868
59- if ( ! outputDir . Exists )
69+ if ( studyPath != null )
70+ {
71+ if ( ! studyPath . Exists )
72+ {
73+ Console . WriteLine ( $ "Error: Study file not found: { studyPath . FullName } ") ;
74+ return ;
75+ }
76+
77+ string studyName = Path . GetFileNameWithoutExtension ( studyPath . Name ) ;
78+ string studyDir = studyPath . DirectoryName ! ;
79+
80+ Console . WriteLine ( $ "Direct study mode: { studyPath . FullName } ") ;
81+ config = new TestConfiguration
82+ {
83+ TestSuiteId = $ "direct-{ studyName } ",
84+ Studies = new List < StudyConfiguration >
85+ {
86+ new ( )
87+ {
88+ StudyId = studyName ,
89+ StudyName = studyName ,
90+ NetworkSourcePath = studyDir ,
91+ RunAllStageDamage = true ,
92+ RunAllScenarios = true ,
93+ RunAllAlternatives = true ,
94+ RunAllAlternativeComparisons = true ,
95+ }
96+ }
97+ } ;
98+
99+ outputPath = outputDir ? . FullName ?? studyDir ;
100+ }
101+ else
60102 {
61- outputDir . Create ( ) ;
103+ if ( ! configFile ! . Exists )
104+ {
105+ Console . WriteLine ( $ "Error: Configuration file not found: { configFile . FullName } ") ;
106+ return ;
107+ }
108+
109+ Console . WriteLine ( $ "Loading configuration: { configFile . FullName } ") ;
110+ config = TestConfiguration . LoadFromFile ( configFile . FullName ) ;
111+ outputPath = outputDir ? . FullName ?? Environment . CurrentDirectory ;
62112 }
63113
114+ Directory . CreateDirectory ( outputPath ) ;
115+
64116 ComputeRunner runner = new (
65117 config ,
66- outputDir . FullName ,
118+ outputPath ,
67119 studyFilter ? . Length > 0 ? studyFilter : null ) ;
68120
69121 await runner . RunAsync ( ) ;
@@ -73,12 +125,12 @@ public static async Task<int> Main(string[] args)
73125 Console . WriteLine ( $ "Fatal error: { ex . Message } ") ;
74126 Console . WriteLine ( ex . StackTrace ) ;
75127 }
76- } , computeConfigOption , computeOutputOption , computeStudyOption ) ;
128+ } , computeConfigOption , studyPathOption , computeOutputOption , computeStudyOption ) ;
77129
78130 // Add subcommands to root
79131 rootCommand . AddCommand ( computeCommand ) ;
80132
81133 // Run
82134 return await rootCommand . InvokeAsync ( args ) ;
83135 }
84- }
136+ }
0 commit comments