private void AddParameter(TreeNode parametersNode, CommandParameter parameter, bool detailed) { if (!detailed) { parametersNode.AddNode( $"{parameter.PropertyName} [purple]{GetShortOptions(parameter)}[/] [grey]{parameter.Property.PropertyType.ToString().EscapeMarkup()}[/]"); return; } var parameterNode = parametersNode.AddNode( $"{parameter.PropertyName} [grey]{parameter.Property.PropertyType.ToString().EscapeMarkup()}[/]"); parameterNode.AddNode(ValueMarkup("Description", parameter.Description, "no description")); parameterNode.AddNode(ValueMarkup("Parameter Kind", parameter.ParameterKind.ToString())); if (parameter is CommandOption commandOptionParameter) { if (commandOptionParameter.IsShadowed) { parameterNode.AddNode(ValueMarkup("IsShadowed", commandOptionParameter.IsShadowed.ToString())); } if (commandOptionParameter.LongNames.Count > 0) { parameterNode.AddNode(ValueMarkup( "Long Names", string.Join("|", commandOptionParameter.LongNames.Select(i => $"--{i}")))); parameterNode.AddNode(ValueMarkup( "Short Names", string.Join("|", commandOptionParameter.ShortNames.Select(i => $"-{i}")))); } } else if (parameter is CommandArgument commandArgumentParameter) { parameterNode.AddNode(ValueMarkup("Position", commandArgumentParameter.Position.ToString())); parameterNode.AddNode(ValueMarkup("Value", commandArgumentParameter.Value)); } parameterNode.AddNode(ValueMarkup("Required", parameter.Required.ToString())); if (parameter.Converter != null) { parameterNode.AddNode(ValueMarkup( "Converter", $"\"{parameter.Converter.ConverterTypeName}\"")); } if (parameter.DefaultValue != null) { parameterNode.AddNode(ValueMarkup( "Default Value", $"\"{parameter.DefaultValue.Value}\"")); } if (parameter.PairDeconstructor != null) { parameterNode.AddNode(ValueMarkup("Pair Deconstructor", parameter.PairDeconstructor.Type.ToString())); } AddStringList( parameterNode, "Validators", parameter.Validators.Select(i => i.GetType().ToString()).ToList()); }
internal static CommandRuntimeException NoConverterFound(CommandParameter parameter) { return(new CommandRuntimeException($"Could not find converter for type '{parameter.ParameterType.FullName}'.")); }