mirror of
https://github.com/Tyrrrz/CliFx.git
synced 2025-10-25 15:19:17 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aa3094ee54 | ||
|
|
712580e3d7 | ||
|
|
c08102f85f |
@@ -1,3 +1,7 @@
|
||||
### v2.2.1 (16-Jan-2022)
|
||||
|
||||
- Fixed an issue which caused help text to not show default values for optional parameters. (Thanks [@AliReZa Sabouri](https://github.com/alirezanet))
|
||||
|
||||
### v2.2 (11-Jan-2022)
|
||||
|
||||
- Added support for optional parameters. A parameter can be marked as optional by setting `IsRequired = false` on the attribute. Only one parameter is allowed to be optional and such parameter must be the last in order. (Thanks [@AliReZa Sabouri](https://github.com/alirezanet))
|
||||
|
||||
@@ -207,6 +207,12 @@ internal class HelpConsoleFormatter : ConsoleFormatter
|
||||
Write(' ');
|
||||
}
|
||||
|
||||
// Default value
|
||||
if (!parameterSchema.IsRequired)
|
||||
{
|
||||
WriteDefaultValue(parameterSchema);
|
||||
}
|
||||
|
||||
WriteLine();
|
||||
}
|
||||
}
|
||||
@@ -298,7 +304,16 @@ internal class HelpConsoleFormatter : ConsoleFormatter
|
||||
// Default value
|
||||
if (!optionSchema.IsRequired)
|
||||
{
|
||||
var defaultValue = _context.CommandDefaultValues.GetValueOrDefault(optionSchema);
|
||||
WriteDefaultValue(optionSchema);
|
||||
}
|
||||
|
||||
WriteLine();
|
||||
}
|
||||
}
|
||||
|
||||
private void WriteDefaultValue(IMemberSchema schema)
|
||||
{
|
||||
var defaultValue = _context.CommandDefaultValues.GetValueOrDefault(schema);
|
||||
if (defaultValue is not null)
|
||||
{
|
||||
// Non-Scalar
|
||||
@@ -348,10 +363,6 @@ internal class HelpConsoleFormatter : ConsoleFormatter
|
||||
}
|
||||
}
|
||||
|
||||
WriteLine();
|
||||
}
|
||||
}
|
||||
|
||||
private void WriteCommandChildren()
|
||||
{
|
||||
var childCommandSchemas = _context
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<Project>
|
||||
|
||||
<PropertyGroup>
|
||||
<Version>2.2</Version>
|
||||
<Version>2.2.1</Version>
|
||||
<Company>Tyrrrz</Company>
|
||||
<Copyright>Copyright (C) Alexey Golub</Copyright>
|
||||
<Copyright>Copyright (C) Oleksii Holub</Copyright>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<WarningsAsErrors>nullable</WarningsAsErrors>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019-2022 Alexey Golub
|
||||
Copyright (c) 2019-2022 Oleksii Holub
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
Reference in New Issue
Block a user