File tree Expand file tree Collapse file tree 1 file changed +19
-4
lines changed
Expand file tree Collapse file tree 1 file changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -20,19 +20,34 @@ public async Task RunAsync()
2020 }
2121
2222 Console . Clear ( ) ;
23- DumpConfig ( ) ;
23+ FinalizeProcess ( ) ;
2424 }
2525
26- private void DumpConfig ( )
26+ private void FinalizeProcess ( )
2727 {
28- var config = JsonSerializer . Serialize ( ConfigRoot , new JsonSerializerOptions ( )
28+ var configJson = JsonSerializer . Serialize ( ConfigRoot , new JsonSerializerOptions ( )
2929 {
3030 WriteIndented = true ,
3131 PropertyNamingPolicy = null ,
3232 DictionaryKeyPolicy = null
3333 } ) ;
3434
35- Console . WriteLine ( config ) ;
35+ Console . WriteLine ( "Your configuration:" ) ;
36+ Console . WriteLine ( configJson ) ;
37+
38+ var saveToFile = CLIPrompt . Bool ( "Do you want to save the configuration to a file?" ) ;
39+ if ( saveToFile )
40+ {
41+ var filePath = CLIPrompt . String ( "Enter the file path to save the configuration [./appsettings.Production.json]:" ) ;
42+ if ( string . IsNullOrWhiteSpace ( filePath ) )
43+ {
44+ var assemblyPath = AppContext . BaseDirectory ;
45+ filePath = Path . Combine ( assemblyPath , "appsettings.Production.json" ) ;
46+ }
47+
48+ File . WriteAllText ( filePath , configJson ) ;
49+ Console . WriteLine ( $ "Configuration saved to { filePath } ") ;
50+ }
3651 }
3752
3853 internal void PushScreen ( CLIScreen screen )
You can’t perform that action at this time.
0 commit comments