files tree made better.

This commit is contained in:
Paul Schneider 2019-01-01 16:28:47 +00:00
commit ccc91bbf19
1630 changed files with 18209 additions and 41860 deletions

View file

@ -0,0 +1,31 @@
using cli.Model;
using Microsoft.Extensions.CommandLineUtils;
namespace cli.Commands
{
public class AuthCommander : ICommander
{
public CommandLineApplication Integrate(CommandLineApplication rootApp)
{
CommandLineApplication authApp = rootApp.Command("auth",
(target) =>
{
target.FullName = "Authentication methods";
target.Description = "Login, save credentials and get authorized.";
target.HelpOption("-? | -h | --help");
var loginCommand = target.Command("login", app => {
var loginarg = app.Argument("login", "login to use", true);
app.Option( "-s | --save", "Save authentication token to file", CommandOptionType.NoValue);
app.HelpOption("-? | -h | --help");
} );
}, false);
authApp.OnExecute(()=>
{
return 0;
});
return authApp;
}
}
}

View file

@ -0,0 +1,28 @@
using cli.Model;
using Microsoft.Extensions.CommandLineUtils;
namespace cli
{
public class CiBuildCommand : ICommander
{
public CommandLineApplication Integrate(CommandLineApplication rootApp)
{
CommandLineApplication ciBuildApp = rootApp.Command("build",
(target) =>
{
target.FullName = "Build this project.";
target.Description = "Build this project, as specified in .paul-ci.json";
target.HelpOption("-? | -h | --help");
}, false);
ciBuildApp.OnExecute(()=>
{
return 0;
});
return ciBuildApp;
}
}
}

View file

@ -0,0 +1,69 @@
using Microsoft.Extensions.CommandLineUtils;
using System.Threading.Tasks;
using NJsonSchema;
using System.IO;
using cli.Model;
namespace cli
{
public class GenerateJsonSchema : ICommander
{
public CommandLineApplication Integrate(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); */
}
}
}

View file

@ -0,0 +1,55 @@
using Microsoft.AspNet.Hosting;
using Microsoft.Extensions.CommandLineUtils;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using cli.Services;
using cli.Model;
namespace cli {
public class SendMailCommandProvider : ICommander {
public CommandLineApplication Integrate(CommandLineApplication rootApp)
{
CommandArgument sendMailCommandArg = null;
CommandOption sendHelpOption = null;
CommandLineApplication sendMailCommandApp
= rootApp.Command("send",
(target) =>
{
target.FullName = "Send email";
target.Description = "Sends emails using given template";
sendHelpOption = target.HelpOption("-? | -h | --help");
sendMailCommandArg = target.Argument(
"class",
"class name of mailling to execute (actually, only 'monthly') .",
multipleValues: true);
}, false);
sendMailCommandApp.OnExecute(() =>
{
if (sendMailCommandArg.Value == "monthly")
{
var host = new WebHostBuilder();
var hostengnine = host.UseEnvironment("Development")
.UseServer("cli")
.UseStartup<Startup>()
.Build();
var app = hostengnine.Start();
var mailer = app.Services.GetService<EMailer>();
var loggerFactory = app.Services.GetService<ILoggerFactory>();
var logger = loggerFactory.CreateLogger<cli.Program>();
logger.LogInformation("Starting emailling");
mailer.SendMonthlyEmail(1, "UserOrientedTemplate");
logger.LogInformation("Finished emailling");
}
else
{
sendMailCommandApp.ShowHelp();
}
return 0;
});
return sendMailCommandApp;
}
}
}