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
|
||||
{
|
||||
{ Length: >= 2 } => "--" + identifier,
|
||||
_ => '-' + identifier
|
||||
_ => '-' + identifier,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -143,26 +143,25 @@ internal static class CommandInputSchemaExtensions
|
||||
{
|
||||
CommandParameterSchema => "Parameter",
|
||||
CommandOptionSchema => "Option",
|
||||
_ => throw new InvalidOperationException("Unknown input schema type.")
|
||||
_ => throw new InvalidOperationException("Unknown input schema type."),
|
||||
};
|
||||
|
||||
public static string GetFormattedIdentifier(this CommandInputSchema schema) =>
|
||||
schema switch
|
||||
{
|
||||
CommandParameterSchema parameter
|
||||
=> parameter.IsSequence ? $"<{parameter.Name}>" : $"<{parameter.Name}...>",
|
||||
CommandOptionSchema option
|
||||
=> option switch
|
||||
{
|
||||
{ Name: not null, ShortName: not null }
|
||||
=> $"-{option.ShortName}|--{option.Name}",
|
||||
{ Name: not null } => $"--{option.Name}",
|
||||
{ ShortName: not null } => $"-{option.ShortName}",
|
||||
_
|
||||
=> throw new InvalidOperationException(
|
||||
"Option must have a name or a short name."
|
||||
)
|
||||
},
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(schema))
|
||||
CommandParameterSchema parameter => parameter.IsSequence
|
||||
? $"<{parameter.Name}>"
|
||||
: $"<{parameter.Name}...>",
|
||||
|
||||
CommandOptionSchema option => option switch
|
||||
{
|
||||
{ Name: not null, ShortName: not null } => $"-{option.ShortName}|--{option.Name}",
|
||||
{ Name: not null } => $"--{option.Name}",
|
||||
{ ShortName: not null } => $"-{option.ShortName}",
|
||||
_ => throw new InvalidOperationException(
|
||||
"Option must have a name or a short name."
|
||||
),
|
||||
},
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(schema)),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user