-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
46 lines (39 loc) · 1.74 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.Extensions.Cli.Utils;
using Microsoft.Extensions.CommandLineUtils;
namespace GuardRex.JsonToCsprojConverter
{
public class Program
{
public static int Main(string[] args)
{
var app = new CommandLineApplication
{
Name = "guardrex-json-to-csproj-converter",
FullName = "GuardRex JSON to CSPROJ Converter",
Description = "Converts project.json into a .csproj file for the project",
};
app.HelpOption("-h|--help");
var frameworkOption = app.Option("-f|--framework <FRAMEWORK>", "Target framework of application being published", CommandOptionType.SingleValue);
var configurationOption = app.Option("-c|--configuration <CONFIGURATION>", "Target configuration of application being published", CommandOptionType.SingleValue);
var projectPath = app.Argument("<PROJECT>", "The path to the project (project folder or project.json) being published. If empty the current directory is used.");
app.OnExecute(() =>
{
var exitCode = new ConvertCommand(frameworkOption.Value(), configurationOption.Value(), projectPath.Value).Run();
return exitCode;
});
try
{
return app.Execute(args);
}
catch (Exception e)
{
Reporter.Error.WriteLine(e.Message.Red());
Reporter.Output.WriteLine(e.ToString().Yellow());
}
return 1;
}
}
}