refact
This commit is contained in:
5
cli/.paul-ci.json
Normal file
5
cli/.paul-ci.json
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"build": {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
73
cli/Commands/GenerateJsonSchema.cs
Normal file
73
cli/Commands/GenerateJsonSchema.cs
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
|
||||||
|
using Microsoft.AspNet.Hosting;
|
||||||
|
using Microsoft.Extensions.CommandLineUtils;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using cli.Services;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using NJsonSchema;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace cli
|
||||||
|
{
|
||||||
|
|
||||||
|
public class GenerateJsonSchema
|
||||||
|
{
|
||||||
|
public CommandLineApplication Integrates(CommandLineApplication rootApp)
|
||||||
|
{
|
||||||
|
CommandArgument genargclass = null;
|
||||||
|
CommandArgument genargjson = null;
|
||||||
|
CommandOption genopthelp = null;
|
||||||
|
var cmd = rootApp.Command("gen",
|
||||||
|
(target) =>
|
||||||
|
{
|
||||||
|
target.FullName = "Generete";
|
||||||
|
target.Description = "generates some objects ...";
|
||||||
|
genopthelp = target.HelpOption("-? | -h | --help");
|
||||||
|
genargclass = target.Argument(
|
||||||
|
"class",
|
||||||
|
"class name of generation to execute (actually, only 'jsonSchema') .",
|
||||||
|
multipleValues: false);
|
||||||
|
genargjson = target.Argument(
|
||||||
|
"json",
|
||||||
|
"Json file to generate a schema for.",
|
||||||
|
multipleValues: false);
|
||||||
|
}, false);
|
||||||
|
cmd.OnExecute(
|
||||||
|
async () => {
|
||||||
|
if (genargjson.Value == "jsonSchema") {
|
||||||
|
if (genargjson.Value == null)
|
||||||
|
await GenerateCiBuildSettingsSchema();
|
||||||
|
else
|
||||||
|
await GenerateCiBuildSettingsSchema(genargjson.Value);
|
||||||
|
} else {
|
||||||
|
cmd.ShowHint();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return cmd;
|
||||||
|
}
|
||||||
|
public static async Task GenerateCiBuildSettingsSchema(string outputFileName = "pauls-ci-schema.json")
|
||||||
|
{
|
||||||
|
var schema = await JsonSchema4.FromTypeAsync<CiBuildSettings>();
|
||||||
|
var schemaData = schema.ToJson();
|
||||||
|
|
||||||
|
FileInfo ofi = new FileInfo(outputFileName);
|
||||||
|
var ostream = ofi.OpenWrite();
|
||||||
|
var owritter = new StreamWriter(ostream);
|
||||||
|
owritter.WriteLine(schemaData);
|
||||||
|
owritter.Close();
|
||||||
|
ostream.Close();
|
||||||
|
/* var errors = schema.Validate("{...}");
|
||||||
|
|
||||||
|
foreach (var error in errors)
|
||||||
|
Console.WriteLine(error.Path + ": " + error.Kind);
|
||||||
|
|
||||||
|
schema = await JsonSchema4.FromJsonAsync(schemaData); */
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -7,19 +7,19 @@ using cli.Services;
|
|||||||
|
|
||||||
namespace cli {
|
namespace cli {
|
||||||
|
|
||||||
public class SendMailCommandProvider {
|
public class SendMailCommandProvider : ICliCommand {
|
||||||
public static CommandLineApplication Handle(CommandLineApplication rootApp)
|
public CommandLineApplication Integrates(CommandLineApplication rootApp)
|
||||||
{
|
{
|
||||||
CommandArgument _sendMailCommandArg = null;
|
CommandArgument sendMailCommandArg = null;
|
||||||
CommandOption _sendHelpOption = null;
|
CommandOption sendHelpOption = null;
|
||||||
CommandLineApplication sendMailCommandApp
|
CommandLineApplication sendMailCommandApp
|
||||||
= rootApp.Command("send",
|
= rootApp.Command("send",
|
||||||
(target) =>
|
(target) =>
|
||||||
{
|
{
|
||||||
target.FullName = "Send email";
|
target.FullName = "Send email";
|
||||||
target.Description = "Sends emails using given template";
|
target.Description = "Sends emails using given template";
|
||||||
_sendHelpOption = target.HelpOption("-? | -h | --help");
|
sendHelpOption = target.HelpOption("-? | -h | --help");
|
||||||
_sendMailCommandArg = target.Argument(
|
sendMailCommandArg = target.Argument(
|
||||||
"class",
|
"class",
|
||||||
"class name of mailling to execute (actually, only 'monthly') .",
|
"class name of mailling to execute (actually, only 'monthly') .",
|
||||||
multipleValues: true);
|
multipleValues: true);
|
||||||
@ -27,7 +27,7 @@ public class SendMailCommandProvider {
|
|||||||
|
|
||||||
sendMailCommandApp.OnExecute(() =>
|
sendMailCommandApp.OnExecute(() =>
|
||||||
{
|
{
|
||||||
if (_sendMailCommandArg.Value == "monthly")
|
if (sendMailCommandArg.Value == "monthly")
|
||||||
{
|
{
|
||||||
var host = new WebHostBuilder();
|
var host = new WebHostBuilder();
|
||||||
var hostengnine = host.UseEnvironment("Development")
|
var hostengnine = host.UseEnvironment("Development")
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
public interface ICliTAsk
|
using Microsoft.Extensions.CommandLineUtils;
|
||||||
{
|
|
||||||
|
|
||||||
}
|
public interface ICliCommand
|
||||||
|
{
|
||||||
|
CommandLineApplication Integrates(CommandLineApplication rootApp);
|
||||||
|
}
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Microsoft.Extensions.CommandLineUtils;
|
using Microsoft.Extensions.CommandLineUtils;
|
||||||
|
using NJsonSchema;
|
||||||
|
|
||||||
namespace cli
|
namespace cli
|
||||||
{
|
{
|
||||||
public partial class Program
|
public partial class Program
|
||||||
{
|
{
|
||||||
|
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
CommandOption rootCommandHelpOption = null;
|
CommandOption rootCommandHelpOption = null;
|
||||||
@ -13,12 +17,15 @@ namespace cli
|
|||||||
CommandLineApplication cliapp = new CommandLineApplication(false);
|
CommandLineApplication cliapp = new CommandLineApplication(false);
|
||||||
cliapp.Name = "cli";
|
cliapp.Name = "cli";
|
||||||
cliapp.FullName = "Yavsc command line interface";
|
cliapp.FullName = "Yavsc command line interface";
|
||||||
cliapp.Description = "Dnx console for yavsc server side";
|
cliapp.Description = "Dnx console app for yavsc server side";
|
||||||
cliapp.ShortVersionGetter = () => "v1.0";
|
cliapp.ShortVersionGetter = () => "v1.0";
|
||||||
cliapp.LongVersionGetter = () => "version 1.0 (stable)";
|
cliapp.LongVersionGetter = () => "version 1.0 (stable)";
|
||||||
rootCommandHelpOption = cliapp.HelpOption("-? | -h | --help");
|
rootCommandHelpOption = cliapp.HelpOption("-? | -h | --help");
|
||||||
|
var command = new SendMailCommandProvider();
|
||||||
|
command.Integrates(cliapp);
|
||||||
|
var gencmd = new GenerateJsonSchema();
|
||||||
|
gencmd.Integrates(cliapp);
|
||||||
|
|
||||||
var sb = SendMailCommandProvider.Handle(cliapp);
|
|
||||||
if (args.Length == 0)
|
if (args.Length == 0)
|
||||||
{
|
{
|
||||||
cliapp.ShowHint();
|
cliapp.ShowHint();
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
"Microsoft.Framework.Configuration.Json": "1.0.0-beta8",
|
"Microsoft.Framework.Configuration.Json": "1.0.0-beta8",
|
||||||
"Microsoft.Framework.ConfigurationModel.Json": "1.0.0-beta4",
|
"Microsoft.Framework.ConfigurationModel.Json": "1.0.0-beta4",
|
||||||
"Newtonsoft.Json": "9.0.1",
|
"Newtonsoft.Json": "9.0.1",
|
||||||
|
"NJsonSchema.CodeGeneration.CSharp": "9.10.65",
|
||||||
"Yavsc": {
|
"Yavsc": {
|
||||||
"version": "1.0.5-rc22",
|
"version": "1.0.5-rc22",
|
||||||
"target": "package"
|
"target": "package"
|
||||||
|
Reference in New Issue
Block a user