using Newtonsoft.Json; using Newtonsoft.Json.Converters; namespace Unity.Pipeline { /// /// One machine-readable argument-binding defect, reported in /api/exec's /// argProblems array. /// /// The vocabulary matches the unity CLI's own ArgProblemKind one-for-one, plus /// , which needs the declared CLR type and so can /// only come from the server. Field names mirror the CLI's record exactly, so neither side /// needs a translation table. /// /// Deliberately machine-readable rather than pre-rendered English: the CLI renders AND /// LOCALIZES these itself across 10 locales. A server sending prose would make /// unity command the one surface that answers in English while the rest of the CLI /// localizes. The envelope's errorDetails carries the English fallback for curl, MCP, /// and for kinds a client has never heard of. /// public class ArgProblem { /// The kind of issue with provided argument. [JsonProperty("kind")] [JsonConverter(typeof(StringEnumConverter), true)] public ArgProblemKind Kind { get; set; } /// The offending raw token, where the defect is about a token. [JsonProperty("token", NullValueHandling = NullValueHandling.Ignore)] public string Token { get; set; } /// The parameter name involved, where the defect is about a name. [JsonProperty("name", NullValueHandling = NullValueHandling.Ignore)] public string Name { get; set; } /// A did-you-mean candidate for . [JsonProperty("suggestion", NullValueHandling = NullValueHandling.Ignore)] public string Suggestion { get; set; } /// Declared positional slots, for . [JsonProperty("capacity", NullValueHandling = NullValueHandling.Ignore)] public int? Capacity { get; set; } /// Positionals supplied, for . [JsonProperty("given", NullValueHandling = NullValueHandling.Ignore)] public int? Given { get; set; } /// /// The declared CLR type name, for . Sent as /// Int32-style short names, matching what the catalog's schema already reports. /// [JsonProperty("expectedType", NullValueHandling = NullValueHandling.Ignore)] public string ExpectedType { get; set; } } /// /// Kinds of argument-binding defect. Serialized camelCase (unknownName) to match the /// CLI's wire expectations; the C# spelling stays PascalCase per package convention. /// public enum ArgProblemKind { // Shape — schema-independent. /// /// A flag with no name: --= or --=value. /// /// Not a bare --: the first one is the end-of-flags separator and is consumed /// before any name parsing, and every later one is a positional. /// EmptyName, /// --key= with nothing after the =. EmptyValue, /// A -x token in positional position (never a flag's value). SingleDash, /// The same --key supplied more than once. Duplicate, // Names — requires the declared-parameter array. /// --nope, or --group-by when the command declares group_by. UnknownName, /// A bare key=value positional whose left side names a real parameter. BareAssignment, /// More positionals than the command has parameter slots. ExcessPositional, /// A positional whose slot was already filled by an explicit flag. PositionalConflict, /// /// A token the declared parameter type cannot accept. Detectable only by the server, /// which has the real . /// TypeMismatch, } }