-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
53 lines (47 loc) · 1.66 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
47
48
49
50
51
52
53
using DotNetSolutionsMerger;
using System.CommandLine;
class Program
{
static async Task<int> Main(string[] args)
{
var rootCommand = new RootCommand("Merge multiple .NET solution files into a single solution.");
var inputOption = new Option<string[]>(
aliases: new[] { "--input", "-i" },
description: "Input solution file paths or directory containing solution files.")
{
AllowMultipleArgumentsPerToken = true,
IsRequired = true
};
var outputOption = new Option<string>(
aliases: new[] { "--output", "-o" },
description: "Output path for the merged solution file.")
{
IsRequired = true
};
rootCommand.AddOption(inputOption);
rootCommand.AddOption(outputOption);
rootCommand.SetHandler((string[] inputs, string output) =>
{
try
{
if (inputs.Length == 1 && Directory.Exists(inputs[0]))
{
// Input is a directory
SolutionMerger.MergeSolutions(inputs[0], output);
}
else
{
// Input is a list of solution files
SolutionMerger.MergeSolutions(inputs, output);
}
Console.WriteLine($"Solutions merged successfully. Output: {output}");
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex.Message}");
Environment.Exit(1);
}
}, inputOption, outputOption);
return await rootCommand.InvokeAsync(args);
}
}