-
-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathProgram.cs
More file actions
72 lines (63 loc) · 2.74 KB
/
Copy pathProgram.cs
File metadata and controls
72 lines (63 loc) · 2.74 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using MaxRev.Gdal.CLI;
using System.Runtime.InteropServices;
namespace MaxRev.Gdal.Core.Tests.CLI
{
internal static class Program
{
private static async Task<int> Main()
{
try
{
Console.WriteLine($"OS: {RuntimeInformation.OSDescription}");
Console.WriteLine($"Arch: {RuntimeInformation.OSArchitecture}");
var tools = GdalCli.GetAvailableTools();
Console.WriteLine($"Found {tools.Count} available tools:");
foreach (var tool in tools)
{
Console.WriteLine($"Available tool: {tool}");
}
GdalCli.EnsureEnvironment();
var toolsToCheck = new[] { "gdalinfo", "ogr2ogr", "gdal_translate" };
foreach (var tool in toolsToCheck)
{
Console.WriteLine($"Running {tool} --version");
var toolPath = GdalCli.GetToolPath(tool);
Console.WriteLine($"Tool path: {toolPath ?? "<not found>"}");
if (string.IsNullOrEmpty(toolPath))
{
Console.Error.WriteLine($"Tool '{tool}' not found");
return 1;
}
var exitCode = GdalCli.Run(tool, new[] { "--version" },
stdout: s => Console.WriteLine($"[GdalCli stdout] {s}"),
stderr: s => Console.Error.WriteLine($"[GdalCli stderr] {s}"));
if (exitCode != 0)
{
Console.Error.WriteLine($"{tool} failed with exit code {exitCode}");
return exitCode;
}
}
// Verify the async API returns the same successful exit codes.
foreach (var tool in toolsToCheck)
{
Console.WriteLine($"Running (async) {tool} --version");
var exitCode = await GdalCli.RunAsync(tool, new[] { "--version" },
stdout: s => Console.WriteLine($"[GdalCli async stdout] {s}"),
stderr: s => Console.Error.WriteLine($"[GdalCli async stderr] {s}"));
if (exitCode != 0)
{
Console.Error.WriteLine($"{tool} (async) failed with exit code {exitCode}");
return exitCode;
}
}
Console.WriteLine("CLI tools executed successfully.");
return 0;
}
catch (Exception ex)
{
Console.Error.WriteLine(ex);
return 1;
}
}
}
}