From 74cba91c4ef954d0493052a68a6fd0e8db6441e6 Mon Sep 17 00:00:00 2001 From: black-eagle17 Date: Sat, 28 Aug 2021 21:23:51 -0400 Subject: [PATCH] dynamically extract manifest data using reflection --- yuniql-cli/CommandLineService.cs | 54 +++++----------------- yuniql-extensibility/ManifestData.cs | 28 +++++++++-- yuniql-platforms/mysql/MySqlDataService.cs | 6 +-- 3 files changed, 38 insertions(+), 50 deletions(-) diff --git a/yuniql-cli/CommandLineService.cs b/yuniql-cli/CommandLineService.cs index 59f05d0..276b011 100644 --- a/yuniql-cli/CommandLineService.cs +++ b/yuniql-cli/CommandLineService.cs @@ -302,49 +302,19 @@ public int RunPlatformsOption(PlatformsOption opts) { try { - string platforms = @"Supported database platforms and available samples. For specific versions, please refer to latest documentation pages."; - -// //TODO: show released, preview, alpha, beta -// SqlServer | Released: -// Supported versions: https://yuniql.io/docs/supported-platforms/ -// Usage: yuniql run -a -c --platform sqlserver -// Samples: https://github.com/rdagumampan/yuniql/tree/master/samples/basic-sqlserver-sample - -// PostgreSql | Released: -// Supported versions: https://yuniql.io/docs/supported-platforms/ -// Usage: yuniql run -a -c --platform postgresql -// Samples: https://github.com/rdagumampan/yuniql/tree/master/samples/basic-postgresql-sample - -// MySql | Released: -// Supported versions: https://yuniql.io/docs/supported-platforms/ -// Usage: yuniql run -a -c --platform mysql -// Samples: https://github.com/rdagumampan/yuniql/tree/master/samples/basic-mysql-sample - -// MariaDb | Released: -// Supported versions: https://yuniql.io/docs/supported-platforms/ -// Supported versions: -// Usage: yuniql run -a -c --platform mariadb -// Samples: https://github.com/rdagumampan/yuniql/tree/master/samples/basic-mysql-sample - -// Snowflake | Preview: -// Supported versions: https://yuniql.io/docs/supported-platforms/ -// Supported versions: -// Usage: yuniql run -a -c --platform snowflake -// Samples: https://github.com/rdagumampan/yuniql/tree/master/samples/basic-snowflake-sample - -// Redshift| Preview: -// Supported versions: https://yuniql.io/docs/supported-platforms/ -// Supported versions: -// Usage: yuniql run -a -c --platform redshift -// Samples: https://github.com/rdagumampan/yuniql/tree/master/samples/basic-redshift-sample -// "; - - Console.WriteLine(platforms); - - var _dataService = _dataServiceFactory.Create("mysql"); - var _manifestData =_dataService.GetManifestData(); - _manifestData.printData(); + Console.WriteLine(@"Supported database platforms and available samples. For specific versions, please refer to latest documentation pages."); + //iterate through supported db and get manifest data + var fields = typeof(SUPPORTED_DATABASES).GetFields(); + foreach (var field in fields) + { + if(field.Name.ToLower() != SUPPORTED_DATABASES.MARIADB) //extra check since mariadb is not yet fully supported[SHOULD CHANGE IN THE FUTURE] + { + var _dataService = _dataServiceFactory.Create(field.Name); + var _manifestData =_dataService.GetManifestData(); + _manifestData.printData(); + } + } return 0; } diff --git a/yuniql-extensibility/ManifestData.cs b/yuniql-extensibility/ManifestData.cs index 3feadd8..292c635 100644 --- a/yuniql-extensibility/ManifestData.cs +++ b/yuniql-extensibility/ManifestData.cs @@ -7,19 +7,37 @@ namespace Yuniql.Extensibility{ /// public class ManifestData { + /// + ///The name of the supported Database. + /// public string Name; + + /// + ///Versions that are supported for each Database platform. + /// public string SupportedVersions; + + /// + /// An example string showing how to use the CLI interface for each Database. + /// public string Usage; + + /// + /// Useful link to samples of the Database and Yuniql in use. + /// public string Samples; + /// + ///outputs a formatted version of the Manifest Data. + /// public void printData() { var info = string.Format(@" - Name: {0} - SupportedVersions: {1} - Usage:{2} - Samples: {3} - ",Name,SupportedVersions,Usage,Samples); + Name: {0} + SupportedVersions: {1} + Usage:{2} + Samples: {3} + ",Name,SupportedVersions,Usage,Samples); Console.WriteLine(info); } } diff --git a/yuniql-platforms/mysql/MySqlDataService.cs b/yuniql-platforms/mysql/MySqlDataService.cs index f6a9fbb..a30259e 100644 --- a/yuniql-platforms/mysql/MySqlDataService.cs +++ b/yuniql-platforms/mysql/MySqlDataService.cs @@ -14,10 +14,10 @@ public class MySqlDataService : IDataService, IMixableTransaction private readonly ITraceService _traceService; private ManifestData _manifestData = new ManifestData{ - Name = "SqlServer | Released:", + Name = "MySql | Released:", SupportedVersions = "https://yuniql.io/docs/supported-platforms/", - Usage = "yuniql run -a -c --platform sqlserver", - Samples = "https://github.com/rdagumampan/yuniql/tree/master/samples/basic-sqlserver-sample" + Usage = "yuniql run -a -c --platform mysql", + Samples = "https://github.com/rdagumampan/yuniql/tree/master/samples/basic-mysql-sample" }; ///