mirror of
https://github.com/Tyrrrz/CliFx.git
synced 2025-10-25 15:19:17 +00:00
asd
This commit is contained in:
@@ -21,8 +21,7 @@ internal class CommandBinder(ITypeActivator typeActivator)
|
||||
// Custom converter
|
||||
if (inputSchema.Converter is not null)
|
||||
{
|
||||
var converter = typeActivator.CreateInstance<IBindingConverter>(inputSchema.Converter);
|
||||
return converter.Convert(rawValue);
|
||||
return inputSchema.Converter.Convert(rawValue);
|
||||
}
|
||||
|
||||
// Assignable from a string (e.g. string itself, object, etc)
|
||||
@@ -336,7 +335,7 @@ internal class CommandBinder(ITypeActivator typeActivator)
|
||||
// Environment variable
|
||||
else if (environmentVariableInput is not null)
|
||||
{
|
||||
var rawValues = optionSchema.Property.IsScalar()
|
||||
var rawValues = optionSchema.IsScalar
|
||||
? [environmentVariableInput.Value]
|
||||
: environmentVariableInput.SplitValues();
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@ namespace CliFx.Schema;
|
||||
/// </summary>
|
||||
public class OptionSchema(
|
||||
PropertyDescriptor property,
|
||||
bool isScalar,
|
||||
IReadOnlyList<object?>? validValues,
|
||||
string? name,
|
||||
char? shortName,
|
||||
string? environmentVariable,
|
||||
@@ -23,10 +25,10 @@ public class OptionSchema(
|
||||
public PropertyDescriptor Property { get; } = property;
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool IsScalar { get; }
|
||||
public bool IsScalar { get; } = isScalar;
|
||||
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyList<object?>? ValidValues { get; }
|
||||
public IReadOnlyList<object?>? ValidValues { get; } = validValues;
|
||||
|
||||
/// <summary>
|
||||
/// Option name.
|
||||
|
||||
@@ -8,6 +8,8 @@ namespace CliFx.Schema;
|
||||
/// </summary>
|
||||
public class ParameterSchema(
|
||||
PropertyDescriptor property,
|
||||
bool isScalar,
|
||||
IReadOnlyList<object?>? validValues,
|
||||
int order,
|
||||
string name,
|
||||
bool isRequired,
|
||||
@@ -19,6 +21,12 @@ public class ParameterSchema(
|
||||
/// <inheritdoc />
|
||||
public PropertyDescriptor Property { get; } = property;
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool IsScalar { get; } = isScalar;
|
||||
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyList<object?>? ValidValues { get; } = validValues;
|
||||
|
||||
/// <summary>
|
||||
/// Order, in which the parameter is bound from the command-line arguments.
|
||||
/// </summary>
|
||||
@@ -46,5 +54,5 @@ public class ParameterSchema(
|
||||
public IReadOnlyList<IBindingValidator> Validators { get; } = validators;
|
||||
|
||||
internal string GetFormattedIdentifier() =>
|
||||
!Property.IsEnumerable ? $"<{Name}>" : $"<{Name}...>";
|
||||
IsScalar ? $"<{Name}>" : $"<{Name}...>";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user