@@ -58,6 +58,12 @@ public GenerateFormNoDupe() {
5858 class Program
5959 {
6060 static bool isVerbose { get ; set ; }
61+ static void PrintVerbose ( string message ) {
62+ if ( isVerbose ) {
63+ Console . WriteLine ( message ) ;
64+ }
65+
66+ }
6167 public static void WriteJsonToFile < T > ( string fileName , T genForm ) {
6268 //string jsonString = JsonSerializer.Serialize<GenerateForm>(genForm);
6369 //File.WriteAllText(fileName, jsonString);
@@ -155,7 +161,6 @@ public static void ParseJson(string filepath, GenerateForm genForm,
155161 IDictionary < String , BookmarkStart > bookmarkMap = new Dictionary < String , BookmarkStart > ( ) ;
156162 foreach ( BookmarkStart bookmarkStart in wordprocessingDocument . MainDocumentPart . RootElement . Descendants < BookmarkStart > ( ) )
157163 {
158- //Console.WriteLine(bookmarkStart.Name);
159164 bookmarkMap [ bookmarkStart . Name ] = bookmarkStart ;
160165 }
161166
@@ -174,18 +179,15 @@ public static void ParseJson(string filepath, GenerateForm genForm,
174179 //Note: docs say Checked should appear however type is DefaultCheckBoxFormFieldState
175180 //Checked checkboxChecked = checkbox?.GetFirstChild<Checked>();
176181 DefaultCheckBoxFormFieldState checkboxChecked = checkbox ? . GetFirstChild < DefaultCheckBoxFormFieldState > ( ) ;
177- //Console.WriteLine(checkboxChecked?.GetType());
178182 if ( checkboxChecked != null ) {
179- Console . WriteLine ( "" + ( bool ) checkboxChecked . Val ) ;
180- //genForm.checkboxMap[bookmarkStart.Name] = (bool) checkboxChecked.Val;
183+ PrintVerbose ( "" + ( bool ) checkboxChecked . Val ) ;
181184 checkBoxAction ( genForm , bookmarkStart . Name , checkboxChecked ) ;
182185 }
183186 } else if ( FormTypes . FormText . Is ( fcode . Text ) ) {
184187 while ( bookmarkFieldCode . NextSibling < Run > ( ) != null ) {
185188 Text bookmarkText = bookmarkFieldCode . GetFirstChild < Text > ( ) ;
186189 if ( bookmarkText != null ) {
187- Console . WriteLine ( bookmarkText . Text ) ;
188- //genForm.stringMap[bookmarkStart.Name] = bookmarkText.Text;
190+ PrintVerbose ( bookmarkText . Text ) ;
189191 textFieldAction ( genForm , bookmarkStart . Name , bookmarkText ) ;
190192 }
191193 bookmarkFieldCode = bookmarkFieldCode . NextSibling < Run > ( ) ;
@@ -216,19 +218,19 @@ static void Main(string[] args)
216218 genCommand . AddAlias ( "gen" ) ;
217219 genCommand . Add ( templateOption ) ;
218220 genCommand . Add ( jsonOutputOption ) ;
219- genCommand . Handler = CommandHandler . Create < string , string > ( ( template , json ) => {
221+ genCommand . Add ( verboseOption ) ;
222+ genCommand . Handler = CommandHandler . Create < string , string , bool > ( ( template , json , verbose ) => {
223+ isVerbose = verbose ;
220224 GenerateForm genForm = new GenerateForm ( ) ;
221- //Console.WriteLine(template);
222- //Console.WriteLine(json);
223225 GenerateJson ( template , genForm ) ;
224226 WriteJsonToFile ( json , BuildNoDuplicateJson ( genForm ) ) ;
225227 } ) ;
226228 var fillCommand = new Command ( "fill" ) ;
227229 fillCommand . Add ( templateOption ) ;
228230 fillCommand . Add ( jsonInputOption ) ;
229- fillCommand . Handler = CommandHandler . Create < string , string > ( ( template , json ) => {
230- //Console.WriteLine( template);
231- //Console.WriteLine(json) ;
231+ fillCommand . Add ( verboseOption ) ;
232+ fillCommand . Handler = CommandHandler . Create < string , string , bool > ( ( template , json , verbose ) => {
233+ isVerbose = verbose ;
232234 if ( String . IsNullOrEmpty ( json ) ) {
233235 Console . WriteLine ( "Invalid input json file name." ) ;
234236 return ;
0 commit comments