using Launcher.Next.Application; using Launcher.Next.Core; using System.IO; namespace Launcher.Next.App; /// Dedicated, non-Autodesk command route. It deliberately constructs /// only the read-only legacy configuration probe dependency graph. internal static class LegacyConfigurationProbeCli { internal static async Task RunAsync(string[] args) { if (args.Length != 4 || !string.Equals(args[0], "--mode", StringComparison.Ordinal) || !string.Equals(args[1], "LegacyConfigurationProbe", StringComparison.Ordinal) || !string.Equals(args[2], "--config", StringComparison.Ordinal) || string.IsNullOrWhiteSpace(args[3])) return Fail("LEGACY_PROBE_MODE_CONFLICT"); try { if (!Path.IsPathFullyQualified(args[3]) || !File.Exists(args[3]) || Directory.Exists(args[3])) return Fail("LEGACY_PROBE_OVERRIDE_MISSING"); var overrideDocument = LegacyProbeOverrideParser.Parse(await File.ReadAllTextAsync(args[3])); var variables = new LauncherPathVariables(new Dictionary { ["LegacySettingsPath"] = overrideDocument.SettingsXml, ["LegacyDownloadListPath"] = overrideDocument.DownloadListXml, ["LegacyCompatibilityOverlayPath"] = overrideDocument.CompatibilityOverlay, ["LegacyProbeEvidenceRoot"] = overrideDocument.EvidenceOutputRoot }); var resolver = new PathResolver(); var request = new LegacyConfigurationProbeRequest( resolver.ResolveLegacySettingsPath(variables), resolver.ResolveLegacyDownloadListPath(variables), resolver.ResolveLegacyCompatibilityOverlayPath(variables), resolver.ResolveLegacyProbeEvidenceRoot(variables), overrideDocument.SelectedPattern, Guid.NewGuid().ToString("N")); var result = await new LegacyConfigurationProbe(new LegacyConfigurationAdapter()).RunAsync(request); Console.WriteLine(result.TerminalState); return result.TerminalState == "Succeeded" ? 0 : 2; } catch (InvalidOperationException ex) { return Fail(ex.Message); } catch { return Fail("LEGACY_PROBE_INTERNAL_FAILURE"); } } private static int Fail(string code) { Console.Error.WriteLine(code); return 2; } }