Skip to content

Commit

Permalink
dynamically extract manifest data using reflection
Browse files Browse the repository at this point in the history
  • Loading branch information
black-eagle17 committed Aug 29, 2021
1 parent 2fc9d40 commit 74cba91
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 50 deletions.
54 changes: 12 additions & 42 deletions yuniql-cli/CommandLineService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 <your-connection-string> --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 <your-connection-string> --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 <your-connection-string> --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 <your-connection-string> --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 <your-connection-string> --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 <your-connection-string> --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;
}
Expand Down
28 changes: 23 additions & 5 deletions yuniql-extensibility/ManifestData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,37 @@ namespace Yuniql.Extensibility{
/// </summary>
public class ManifestData
{
///<summary>
///The name of the supported Database.
///</summary>
public string Name;

///<summary>
///Versions that are supported for each Database platform.
///</summary>
public string SupportedVersions;

///<summary>
/// An example string showing how to use the CLI interface for each Database.
///</summary>
public string Usage;

///<summary>
/// Useful link to samples of the Database and Yuniql in use.
///</summary>
public string Samples;

///<summary>
///outputs a formatted version of the Manifest Data.
///</summary>
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);
}
}
Expand Down
6 changes: 3 additions & 3 deletions yuniql-platforms/mysql/MySqlDataService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 <your-connection-string> --platform sqlserver",
Samples = "https://github.com/rdagumampan/yuniql/tree/master/samples/basic-sqlserver-sample"
Usage = "yuniql run -a -c <your-connection-string> --platform mysql",
Samples = "https://github.com/rdagumampan/yuniql/tree/master/samples/basic-mysql-sample"
};

///<inheritdoc/>
Expand Down

0 comments on commit 74cba91

Please sign in to comment.