Skip to content

Commit

Permalink
Rework the readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyrrrz committed Mar 2, 2023
1 parent 1c331df commit a09818d
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 177 deletions.
10 changes: 5 additions & 5 deletions CliFx/CommandBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public CommandBinder(ITypeActivator typeActivator)
return converter.Convert(rawValue);
}

// Assignable from string (e.g. string itself, object, etc)
// Assignable from a string (e.g. string itself, object, etc)
if (targetType.IsAssignableFrom(typeof(string)))
{
return rawValue;
Expand Down Expand Up @@ -77,7 +77,7 @@ public CommandBinder(ITypeActivator typeActivator)
: null;
}

// String-constructible (FileInfo, etc)
// String-constructable (FileInfo, etc)
var stringConstructor = targetType.GetConstructor(new[] { typeof(string) });
if (stringConstructor is not null)
{
Expand Down Expand Up @@ -125,7 +125,7 @@ There is no known way to convert a string value into an instance of type `{targe
return array;
}

// Array-constructible (List<T>, HashSet<T>, etc)
// Array-constructable (List<T>, HashSet<T>, etc)
var arrayConstructor = targetEnumerableType.GetConstructor(new[] { arrayType });
if (arrayConstructor is not null)
{
Expand Down Expand Up @@ -307,7 +307,7 @@ private void BindOptions(CommandInput commandInput, CommandSchema commandSchema,

BindMember(optionSchema, commandInstance, rawValues);

// Required options require at least one value to be set
// Required options need at least one value to be set
if (rawValues.Any())
remainingRequiredOptionSchemas.Remove(optionSchema);
}
Expand All @@ -320,7 +320,7 @@ private void BindOptions(CommandInput commandInput, CommandSchema commandSchema,

BindMember(optionSchema, commandInstance, rawValues);

// Required options require at least one value to be set
// Required options need at least one value to be set
if (rawValues.Any())
remainingRequiredOptionSchemas.Remove(optionSchema);
}
Expand Down
5 changes: 2 additions & 3 deletions CliFx/Schema/CommandSchema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ internal partial class CommandSchema
public static bool IsCommandType(Type type) =>
type.Implements(typeof(ICommand)) &&
type.IsDefined(typeof(CommandAttribute)) &&
!type.IsAbstract &&
!type.IsInterface;
type is { IsAbstract: false, IsInterface: false };

public static CommandSchema? TryResolve(Type type)
{
Expand All @@ -88,7 +87,7 @@ public static bool IsCommandType(Type type) =>
: new[] {OptionSchema.HelpOption};

var properties = type
// Get properties directly on command type
// Get properties directly on the command type
.GetProperties()
// Get non-abstract properties on interfaces (to support default interfaces members)
.Union(type
Expand Down
Loading

0 comments on commit a09818d

Please sign in to comment.