@@ -22,6 +22,7 @@ public class ApplicationArguments
2222 public string Table { get ; set ; }
2323 public bool GenerateConstructorAndOutput { get ; set ; }
2424 public bool GenerateMarkupPages { get ; set ; }
25+ public string MarkupDatabaseNameReplacement { get ; set ; }
2526 }
2627
2728 public class Column
@@ -120,29 +121,42 @@ private static void DbToClasses(string dbName, Dictionary<string, List<Column>>
120121
121122 private static void DbToMarkupPage ( string dbName , Dictionary < string , List < Column > > db )
122123 {
123- var wikiDir = $ "{ dbName } -wiki";
124- var wikiTableDir = $ "{ wikiDir } /tables";
124+ var wikiDir = $ "wiki";
125+ var wikiDbDir = $ "{ wikiDir } /{ dbName } ";
126+ var wikiTableDir = $ "{ wikiDbDir } /tables";
125127
126128 if ( ! Directory . Exists ( wikiDir ) )
127129 Directory . CreateDirectory ( wikiDir ) ;
128130 if ( ! Directory . Exists ( wikiTableDir ) )
129131 Directory . CreateDirectory ( wikiTableDir ) ;
130132
131133 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+
132144 // generate index pages
133145 foreach ( var table in db )
134146 sb . AppendLine ( $ "* [[{ table . Key . FirstCharUpper ( ) } |{ table . Key . ToLower ( ) } ]]") ;
135147
136- var sw = new StreamWriter ( $ "{ wikiDir } /{ dbName } .txt") ;
148+ sw = new StreamWriter ( $ "{ wikiDbDir } /{ dbName } .txt") ;
137149 sw . Write ( sb . ToString ( ) ) ;
138150 sw . Close ( ) ;
139151 sb . Clear ( ) ;
140152
141- sb . AppendLine ( "Column | Type | Description" ) ;
142- sb . AppendLine ( "--- | --- | ---" ) ;
143-
144153 foreach ( var table in db )
145154 {
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+
146160 foreach ( var column in table . Value )
147161 sb . AppendLine ( $ "{ column . Name . FirstCharUpper ( ) } | { column . ColumnType } | ") ;
148162 sw = new StreamWriter ( $ "{ wikiTableDir } /{ table . Key } .txt") ;
@@ -167,6 +181,8 @@ static void Main(string[] args)
167181 parser . Setup ( arg => arg . GenerateMarkupPages ) . As ( 'm' , "generatemarkuppages" )
168182 . SetDefault ( false )
169183 . 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" ) ;
170186 parser . SetupHelp ( "?" , "help" ) . Callback ( text => Console . WriteLine ( text ) ) ;
171187
172188 var result = parser . Parse ( args ) ;
@@ -225,7 +241,7 @@ static void Main(string[] args)
225241
226242 DbToClasses ( conf . Database , database , conf . GenerateConstructorAndOutput ) ;
227243 if ( conf . GenerateMarkupPages )
228- DbToMarkupPage ( conf . Database , database ) ;
244+ DbToMarkupPage ( String . IsNullOrEmpty ( conf . MarkupDatabaseNameReplacement ) ? conf . Database : conf . MarkupDatabaseNameReplacement , database ) ;
229245 Console . WriteLine ( "Successfully generated C# classes!" ) ;
230246 }
231247 Console . ReadLine ( ) ;
0 commit comments