namespace FictionArchive.Service.Shared; /// /// Detects if the application is running in schema export mode (for HotChocolate CLI commands). /// In this mode, infrastructure like RabbitMQ and databases should not be initialized. /// public static class SchemaExportDetector { /// /// Checks if the current run is a schema export command. /// /// Command line arguments passed to Main() /// True if running schema export, false otherwise public static bool IsSchemaExportMode(string[] args) { // HotChocolate CLI pattern: "schema export" after "--" delimiter // Handles: dotnet run -- schema export --output schema.graphql var normalizedArgs = args.SkipWhile(a => a == "--").ToArray(); return normalizedArgs.Length > 0 && normalizedArgs[0].Equals("schema", StringComparison.OrdinalIgnoreCase); } }