3 Commits
2.2 ... 2.2.1

Author SHA1 Message Date
Oleksii Holub
aa3094ee54 Update version 2022-01-16 19:29:50 +02:00
Tyrrrz
712580e3d7 Update my name to match correct spelling 2022-01-15 03:24:06 +02:00
AliReZa Sabouri
c08102f85f Show default values for optional parameters (#122) 2022-01-11 05:22:13 -08:00
4 changed files with 66 additions and 51 deletions

View File

@@ -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) ### 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)) - 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))

View File

@@ -207,6 +207,12 @@ internal class HelpConsoleFormatter : ConsoleFormatter
Write(' '); Write(' ');
} }
// Default value
if (!parameterSchema.IsRequired)
{
WriteDefaultValue(parameterSchema);
}
WriteLine(); WriteLine();
} }
} }
@@ -298,7 +304,16 @@ internal class HelpConsoleFormatter : ConsoleFormatter
// Default value // Default value
if (!optionSchema.IsRequired) 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) if (defaultValue is not null)
{ {
// Non-Scalar // Non-Scalar
@@ -348,10 +363,6 @@ internal class HelpConsoleFormatter : ConsoleFormatter
} }
} }
WriteLine();
}
}
private void WriteCommandChildren() private void WriteCommandChildren()
{ {
var childCommandSchemas = _context var childCommandSchemas = _context

View File

@@ -1,9 +1,9 @@
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<Version>2.2</Version> <Version>2.2.1</Version>
<Company>Tyrrrz</Company> <Company>Tyrrrz</Company>
<Copyright>Copyright (C) Alexey Golub</Copyright> <Copyright>Copyright (C) Oleksii Holub</Copyright>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<WarningsAsErrors>nullable</WarningsAsErrors> <WarningsAsErrors>nullable</WarningsAsErrors>

View File

@@ -1,6 +1,6 @@
MIT License 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 Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal