@@ -58,6 +58,12 @@ public GenerateFormNoDupe() {
58
58
class Program
59
59
{
60
60
static bool isVerbose { get ; set ; }
61
+ static void PrintVerbose ( string message ) {
62
+ if ( isVerbose ) {
63
+ Console . WriteLine ( message ) ;
64
+ }
65
+
66
+ }
61
67
public static void WriteJsonToFile < T > ( string fileName , T genForm ) {
62
68
//string jsonString = JsonSerializer.Serialize<GenerateForm>(genForm);
63
69
//File.WriteAllText(fileName, jsonString);
@@ -155,7 +161,6 @@ public static void ParseJson(string filepath, GenerateForm genForm,
155
161
IDictionary < String , BookmarkStart > bookmarkMap = new Dictionary < String , BookmarkStart > ( ) ;
156
162
foreach ( BookmarkStart bookmarkStart in wordprocessingDocument . MainDocumentPart . RootElement . Descendants < BookmarkStart > ( ) )
157
163
{
158
- //Console.WriteLine(bookmarkStart.Name);
159
164
bookmarkMap [ bookmarkStart . Name ] = bookmarkStart ;
160
165
}
161
166
@@ -174,18 +179,15 @@ public static void ParseJson(string filepath, GenerateForm genForm,
174
179
//Note: docs say Checked should appear however type is DefaultCheckBoxFormFieldState
175
180
//Checked checkboxChecked = checkbox?.GetFirstChild<Checked>();
176
181
DefaultCheckBoxFormFieldState checkboxChecked = checkbox ? . GetFirstChild < DefaultCheckBoxFormFieldState > ( ) ;
177
- //Console.WriteLine(checkboxChecked?.GetType());
178
182
if ( checkboxChecked != null ) {
179
- Console . WriteLine ( "" + ( bool ) checkboxChecked . Val ) ;
180
- //genForm.checkboxMap[bookmarkStart.Name] = (bool) checkboxChecked.Val;
183
+ PrintVerbose ( "" + ( bool ) checkboxChecked . Val ) ;
181
184
checkBoxAction ( genForm , bookmarkStart . Name , checkboxChecked ) ;
182
185
}
183
186
} else if ( FormTypes . FormText . Is ( fcode . Text ) ) {
184
187
while ( bookmarkFieldCode . NextSibling < Run > ( ) != null ) {
185
188
Text bookmarkText = bookmarkFieldCode . GetFirstChild < Text > ( ) ;
186
189
if ( bookmarkText != null ) {
187
- Console . WriteLine ( bookmarkText . Text ) ;
188
- //genForm.stringMap[bookmarkStart.Name] = bookmarkText.Text;
190
+ PrintVerbose ( bookmarkText . Text ) ;
189
191
textFieldAction ( genForm , bookmarkStart . Name , bookmarkText ) ;
190
192
}
191
193
bookmarkFieldCode = bookmarkFieldCode . NextSibling < Run > ( ) ;
@@ -216,19 +218,19 @@ static void Main(string[] args)
216
218
genCommand . AddAlias ( "gen" ) ;
217
219
genCommand . Add ( templateOption ) ;
218
220
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 ;
220
224
GenerateForm genForm = new GenerateForm ( ) ;
221
- //Console.WriteLine(template);
222
- //Console.WriteLine(json);
223
225
GenerateJson ( template , genForm ) ;
224
226
WriteJsonToFile ( json , BuildNoDuplicateJson ( genForm ) ) ;
225
227
} ) ;
226
228
var fillCommand = new Command ( "fill" ) ;
227
229
fillCommand . Add ( templateOption ) ;
228
230
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 ;
232
234
if ( String . IsNullOrEmpty ( json ) ) {
233
235
Console . WriteLine ( "Invalid input json file name." ) ;
234
236
return ;
0 commit comments