@@ -22,6 +22,7 @@ public class ApplicationArguments
22
22
public string Table { get ; set ; }
23
23
public bool GenerateConstructorAndOutput { get ; set ; }
24
24
public bool GenerateMarkupPages { get ; set ; }
25
+ public string MarkupDatabaseNameReplacement { get ; set ; }
25
26
}
26
27
27
28
public class Column
@@ -120,29 +121,42 @@ private static void DbToClasses(string dbName, Dictionary<string, List<Column>>
120
121
121
122
private static void DbToMarkupPage ( string dbName , Dictionary < string , List < Column > > db )
122
123
{
123
- var wikiDir = $ "{ dbName } -wiki";
124
- var wikiTableDir = $ "{ wikiDir } /tables";
124
+ var wikiDir = $ "wiki";
125
+ var wikiDbDir = $ "{ wikiDir } /{ dbName } ";
126
+ var wikiTableDir = $ "{ wikiDbDir } /tables";
125
127
126
128
if ( ! Directory . Exists ( wikiDir ) )
127
129
Directory . CreateDirectory ( wikiDir ) ;
128
130
if ( ! Directory . Exists ( wikiTableDir ) )
129
131
Directory . CreateDirectory ( wikiTableDir ) ;
130
132
131
133
var sb = new StringBuilder ( ) ;
134
+
135
+ sb . AppendLine ( $ "* [[{ dbName } |{ dbName } ]]") ;
136
+
137
+ var sw = new StreamWriter ( $ "{ wikiDir } /index.txt", true ) ;
138
+ sw . Write ( sb . ToString ( ) ) ;
139
+ sw . Close ( ) ;
140
+ sb . Clear ( ) ;
141
+
142
+ sb . AppendLine ( $ "[[Database Structure|Database Structure]] > [[{ dbName } |{ dbName } ]]") ;
143
+
132
144
// generate index pages
133
145
foreach ( var table in db )
134
146
sb . AppendLine ( $ "* [[{ table . Key . FirstCharUpper ( ) } |{ table . Key . ToLower ( ) } ]]") ;
135
147
136
- var sw = new StreamWriter ( $ "{ wikiDir } /{ dbName } .txt") ;
148
+ sw = new StreamWriter ( $ "{ wikiDbDir } /{ dbName } .txt") ;
137
149
sw . Write ( sb . ToString ( ) ) ;
138
150
sw . Close ( ) ;
139
151
sb . Clear ( ) ;
140
152
141
- sb . AppendLine ( "Column | Type | Description" ) ;
142
- sb . AppendLine ( "--- | --- | ---" ) ;
143
-
144
153
foreach ( var table in db )
145
154
{
155
+ sb . AppendLine ( $ "[[Database Structure|Database Structure]] > [[{ dbName } |{ dbName } ]] > [[{ table . Key } |{ table . Key } ]]") ;
156
+ sb . AppendLine ( "" ) ;
157
+ sb . AppendLine ( "Column | Type | Description" ) ;
158
+ sb . AppendLine ( "--- | --- | ---" ) ;
159
+
146
160
foreach ( var column in table . Value )
147
161
sb . AppendLine ( $ "{ column . Name . FirstCharUpper ( ) } | { column . ColumnType } | ") ;
148
162
sw = new StreamWriter ( $ "{ wikiTableDir } /{ table . Key } .txt") ;
@@ -167,6 +181,8 @@ static void Main(string[] args)
167
181
parser . Setup ( arg => arg . GenerateMarkupPages ) . As ( 'm' , "generatemarkuppages" )
168
182
. SetDefault ( false )
169
183
. WithDescription ( "(optional) Generate markup pages for database and tables which can be used in wikis - Activate with -m true" ) ;
184
+ parser . Setup ( arg => arg . MarkupDatabaseNameReplacement ) . As ( 'r' , "markupdatabasenamereplacement" )
185
+ . SetDefault ( "" ) . WithDescription ( "(optional) Will use this instead of database name for wiki breadcrump generation" ) ;
170
186
parser . SetupHelp ( "?" , "help" ) . Callback ( text => Console . WriteLine ( text ) ) ;
171
187
172
188
var result = parser . Parse ( args ) ;
@@ -225,7 +241,7 @@ static void Main(string[] args)
225
241
226
242
DbToClasses ( conf . Database , database , conf . GenerateConstructorAndOutput ) ;
227
243
if ( conf . GenerateMarkupPages )
228
- DbToMarkupPage ( conf . Database , database ) ;
244
+ DbToMarkupPage ( String . IsNullOrEmpty ( conf . MarkupDatabaseNameReplacement ) ? conf . Database : conf . MarkupDatabaseNameReplacement , database ) ;
229
245
Console . WriteLine ( "Successfully generated C# classes!" ) ;
230
246
}
231
247
Console . ReadLine ( ) ;
0 commit comments