Skip to content

Commit 4c2b493

Browse files
committed
Add examples for running in Readme. put print under verbose flag
1 parent b03348c commit 4c2b493

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

Program.cs

+14-12
Original file line numberDiff line numberDiff line change
@@ -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;

README.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
- `dotnet build`
88

99
## Run Instructions
10-
- `dotnet run FormGen.exe <flags>`
10+
- `dotnet run <flags>`
11+
- ex. `dotnet run generate -t test.docx`
12+
- ex. `dotnet run gen -t test.docx`
13+
- ex. `dotnet run fill -t test.docx -j output.json`
1114

1215
## cli comands
1316
- `generate`
@@ -24,6 +27,12 @@
2427
- build: `docker build -t formgen:latest .`
2528
- run: `docker run --name docs_vm -it formgen:latest`
2629

30+
## Build For Platforms
31+
- macos 14: `dotnet publish -c Release -r osx.10.14-x64`
32+
- macos: `dotnet publish -c Release -r osx-x64`
33+
- windows: `dotnet publish -c Release -r win-x64`
34+
- linux: `dotnet publish -c Release -r linux-x64`
35+
- see more RID configurations at: https://docs.microsoft.com/en-us/dotnet/core/rid-catalog
2736
## Supported Platform(s)
2837
- OS X
2938
- Linux

0 commit comments

Comments
 (0)