- Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathProgram.cs
More file actions
Latest commit
31 lines (30 loc) · 1.15 KB
/
Copy pathProgram.cs
File metadata and controls
31 lines (30 loc) · 1.15 KB
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
usingSystem.CommandLine;
usingSystem.CommandLine.Invocation;
Console.OutputEncoding=System.Text.Encoding.UTF8;
varinputPathArg=newArgument<string>("inputPath","The path to the .unitypackage file to extract.");
varoutputDirArg=newArgument<string>("outputDir",()=>".","The directory to extract to. A new directory with the same name as the input file (excluding the extension) will be created inside the specified directory.");
varrootCommand=newRootCommand(description:"Extracts the contents of a .unitypackage file into a new directory.")
{
inputPathArg,outputDirArg
};
rootCommand.SetHandler((InvocationContextcontext)=>
{
varextractor=newExtractor
{
InputPath=context.ParseResult.GetValueForArgument(inputPathArg),
OutputDir=context.ParseResult.GetValueForArgument(outputDirArg)
};
try
{
extractor.Extract();
}
catch(Exceptionex)
{
Console.ForegroundColor=ConsoleColor.Red;
Console.Error.WriteLine();
Console.Error.WriteLine($"ERROR: {ex.Message}");
Console.ResetColor();
context.ExitCode=1;
}
});
returnrootCommand.Invoke(args);