mirror of
https://github.com/Tyrrrz/CliFx.git
synced 2025-10-25 15:19:17 +00:00
asd
This commit is contained in:
@@ -16,7 +16,7 @@ public class CommandOptionToken(string identifier, IReadOnlyList<string> values)
|
|||||||
identifier switch
|
identifier switch
|
||||||
{
|
{
|
||||||
{ Length: >= 2 } => "--" + identifier,
|
{ Length: >= 2 } => "--" + identifier,
|
||||||
_ => '-' + identifier
|
_ => '-' + identifier,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -143,26 +143,25 @@ internal static class CommandInputSchemaExtensions
|
|||||||
{
|
{
|
||||||
CommandParameterSchema => "Parameter",
|
CommandParameterSchema => "Parameter",
|
||||||
CommandOptionSchema => "Option",
|
CommandOptionSchema => "Option",
|
||||||
_ => throw new InvalidOperationException("Unknown input schema type.")
|
_ => throw new InvalidOperationException("Unknown input schema type."),
|
||||||
};
|
};
|
||||||
|
|
||||||
public static string GetFormattedIdentifier(this CommandInputSchema schema) =>
|
public static string GetFormattedIdentifier(this CommandInputSchema schema) =>
|
||||||
schema switch
|
schema switch
|
||||||
{
|
{
|
||||||
CommandParameterSchema parameter
|
CommandParameterSchema parameter => parameter.IsSequence
|
||||||
=> parameter.IsSequence ? $"<{parameter.Name}>" : $"<{parameter.Name}...>",
|
? $"<{parameter.Name}>"
|
||||||
CommandOptionSchema option
|
: $"<{parameter.Name}...>",
|
||||||
=> option switch
|
|
||||||
|
CommandOptionSchema option => option switch
|
||||||
{
|
{
|
||||||
{ Name: not null, ShortName: not null }
|
{ Name: not null, ShortName: not null } => $"-{option.ShortName}|--{option.Name}",
|
||||||
=> $"-{option.ShortName}|--{option.Name}",
|
|
||||||
{ Name: not null } => $"--{option.Name}",
|
{ Name: not null } => $"--{option.Name}",
|
||||||
{ ShortName: not null } => $"-{option.ShortName}",
|
{ ShortName: not null } => $"-{option.ShortName}",
|
||||||
_
|
_ => throw new InvalidOperationException(
|
||||||
=> throw new InvalidOperationException(
|
|
||||||
"Option must have a name or a short name."
|
"Option must have a name or a short name."
|
||||||
)
|
),
|
||||||
},
|
},
|
||||||
_ => throw new ArgumentOutOfRangeException(nameof(schema))
|
_ => throw new ArgumentOutOfRangeException(nameof(schema)),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user