Skip to content

Commit c3e4395

Browse files
authoredSep 19, 2023
Merge pull request #21 from SvenGroot/v4.0.1-dev
Merge version 4.0.1 into main.
2 parents 9460f13 + aa0d943 commit c3e4395

12 files changed

+40
-29
lines changed
 

‎docs/ChangeLog.md

+13-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# What’s new in Ookii.CommandLine
22

3-
## Ookii.CommandLine 4.0 - 2023-07-20
3+
## Ookii.CommandLine 4.0.1 (2023-09-19)
4+
5+
- Fix an issue where arguments defined by methods could not have aliases.
6+
7+
## Ookii.CommandLine 4.0 (2023-07-20)
48

59
**IMPORTANT:** Version 4.0 contains breaking changes. If you are upgrading from version 2.x or 3.x,
610
please check the [migration guide](Migrating.md).
@@ -51,12 +55,12 @@ please check the [migration guide](Migrating.md).
5155
- [Source link](https://github.com/dotnet/sourcelink) integration.
5256
- Various bug fixes and minor improvements.
5357

54-
## Ookii.CommandLine 3.1.1 - 2023-03-29
58+
## Ookii.CommandLine 3.1.1 (2023-03-29)
5559

5660
- .Net Standard 2.0: use the System.Memory package to remove some downlevel-only code.
5761
- There are no changes for the .Net Standard 2.1 and .Net 6.0 assemblies.
5862

59-
## Ookii.CommandLine 3.1 - 2023-03-21
63+
## Ookii.CommandLine 3.1 (2023-03-21)
6064

6165
- Added an instance [`CommandLineParser<T>.ParseWithErrorHandling()`][] method, which handles errors
6266
and displays usage help the same way as the static [`Parse<T>()`][Parse<T>()_1] method, but allows access to more
@@ -79,7 +83,7 @@ please check the [migration guide](Migrating.md).
7983
writer yet.
8084
- Some minor bug fixes.
8185

82-
## Ookii.CommandLine 3.0 - 2022-12-01
86+
## Ookii.CommandLine 3.0 (2022-12-01)
8387

8488
**IMPORTANT:** Several of the changes in version 3.0 are *breaking changes*. There are breaking API
8589
changes as well as several behavior changes. In general, it's not expected that you'll need to make
@@ -144,7 +148,7 @@ existing application.
144148
- No longer targets .Net Framework 2.0
145149
- Now targets .Net Standard 2.0, .Net Standard 2.1, and .Net 6.0 and later.
146150

147-
## Ookii.CommandLine 2.4 - 2022-09-01
151+
## Ookii.CommandLine 2.4 (2022-09-01)
148152

149153
- Ookii.CommandLine now comes in a .Net 6.0 version that fully supports nullable reference types
150154
(.Net Framework 2.0 and .Net Standard 2.0 versions are also still provided).
@@ -156,18 +160,18 @@ existing application.
156160
- Arguments can indicate they cancel parsing to make adding a `-Help` or `-?` argument easier.
157161
- Some small bug fixes.
158162

159-
## Ookii.CommandLine 2.3 - 2019-09-05
163+
## Ookii.CommandLine 2.3 (2019-09-05)
160164

161165
- Ookii.CommandLine now comes in both a .Net Framework 2.0 and .Net Standard 2.0 version.
162166

163-
## Ookii.CommandLine 2.2 - 2013-02-06
167+
## Ookii.CommandLine 2.2 (2013-02-06)
164168

165169
- Added support for alternative names (aliases) for command line arguments.
166170
- An argument’s aliases and default value can be included in the argument description when
167171
generating usage.
168172
- Added code snippets.
169173

170-
## Ookii.CommandLine 2.1 - 2012-02-19
174+
## Ookii.CommandLine 2.1 (2012-02-19)
171175

172176
- Added support for dictionary arguments; these are special multi-value arguments whose values take
173177
the form key=value.
@@ -187,7 +191,7 @@ existing application.
187191
- Shell commands can use custom argument parsing.
188192
- Various minor bug fixes.
189193

190-
## Ookii.CommandLine 2.0 - 2011-08-13
194+
## Ookii.CommandLine 2.0 (2011-08-13)
191195

192196
- Improved argument parsing:
193197
- All arguments can be specified by name.

‎src/Create-Release.ps1

58 Bytes
Binary file not shown.

‎src/Directory.Build.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
<Authors>Sven Groot</Authors>
55
<Company>Ookii.org</Company>
66
<Copyright>Copyright (c) Sven Groot (Ookii.org)</Copyright>
7-
<VersionPrefix>4.0.0</VersionPrefix>
7+
<VersionPrefix>4.0.1</VersionPrefix>
88
</PropertyGroup>
99
</Project>

‎src/Ookii.CommandLine.Tests/ArgumentTypes.cs

+8-1
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ partial class CultureArguments
227227
[ParseOptions(Mode = ParsingMode.LongShort)]
228228
partial class LongShortArguments
229229
{
230+
public static bool Switch2Value { get; set; }
231+
230232
[CommandLineArgument, ShortAlias('c')]
231233
[Description("Arg1 description.")]
232234
public int Arg1 { get; set; }
@@ -240,8 +242,13 @@ partial class LongShortArguments
240242
public bool Switch1 { get; set; }
241243

242244
[CommandLineArgument(ShortName = 'k')]
245+
[Alias("Switch2Alias")]
246+
[ShortAlias('x')]
243247
[Description("Switch2 description.")]
244-
public bool Switch2 { get; set; }
248+
public static void Switch2(bool value)
249+
{
250+
Switch2Value = value;
251+
}
245252

246253
[CommandLineArgument(ShortName = 'u', IsLong = false)]
247254
[Description("Switch3 description.")]

‎src/Ookii.CommandLine.Tests/CommandLineParserTest.Usage.cs

+10-10
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Displays this help message.
6363
-S, --Switch1 [<Boolean>]
6464
Switch1 description.
6565
66-
-k, --Switch2 [<Boolean>]
66+
-k, --Switch2 [<Boolean>] (-x, --Switch2Alias)
6767
Switch2 description.
6868
6969
-u [<Boolean>]
@@ -94,7 +94,7 @@ Displays this help message.
9494
-S, --Switch1 [<Boolean>]
9595
Switch1 description.
9696
97-
-k, --Switch2 [<Boolean>]
97+
-k, --Switch2 [<Boolean>] (-x, --Switch2Alias)
9898
Switch2 description.
9999
100100
-u [<Boolean>]
@@ -125,7 +125,7 @@ Displays this help message.
125125
-S, --Switch1 [<Boolean>]
126126
Switch1 description.
127127
128-
-k, --Switch2 [<Boolean>]
128+
-k, --Switch2 [<Boolean>] (-x, --Switch2Alias)
129129
Switch2 description.
130130
131131
-u [<Boolean>]
@@ -290,7 +290,7 @@ Displays this help message.
290290
-S, --Switch1 [<Boolean>]
291291
Switch1 description.
292292
293-
[32m-k, --Switch2 [<Boolean>][0m
293+
[32m-k, --Switch2 [<Boolean>] (-x, --Switch2Alias)[0m
294294
Switch2 description.
295295
296296
-u [<Boolean>]
@@ -417,7 +417,7 @@ Displays this help message.
417417
-S, --Switch1 [<Boolean>]
418418
Switch1 description.
419419
420-
-k, --Switch2 [<Boolean>]
420+
-k, --Switch2 [<Boolean>] (-x, --Switch2Alias)
421421
Switch2 description.
422422
423423
-u [<Boolean>]
@@ -436,7 +436,7 @@ Displays version information.
436436
-u [<Boolean>]
437437
Switch3 description.
438438
439-
-k, --Switch2 [<Boolean>]
439+
-k, --Switch2 [<Boolean>] (-x, --Switch2Alias)
440440
Switch2 description.
441441
442442
-S, --Switch1 [<Boolean>]
@@ -476,7 +476,7 @@ Arg1 description.
476476
-f, --foo <Int32>
477477
Foo description. Default value: 0.
478478
479-
-k, --Switch2 [<Boolean>]
479+
-k, --Switch2 [<Boolean>] (-x, --Switch2Alias)
480480
Switch2 description.
481481
482482
-S, --Switch1 [<Boolean>]
@@ -501,7 +501,7 @@ Switch3 description.
501501
-S, --Switch1 [<Boolean>]
502502
Switch1 description.
503503
504-
-k, --Switch2 [<Boolean>]
504+
-k, --Switch2 [<Boolean>] (-x, --Switch2Alias)
505505
Switch2 description.
506506
507507
-f, --foo <Int32>
@@ -541,7 +541,7 @@ Displays this help message.
541541
-Switch1 [<Boolean>]
542542
Switch1 description.
543543
544-
-Switch2 [<Boolean>]
544+
-Switch2 [<Boolean>] (-Switch2Alias)
545545
Switch2 description.
546546
547547
-Switch3 [<Boolean>]
@@ -560,7 +560,7 @@ Displays version information.
560560
-Switch3 [<Boolean>]
561561
Switch3 description.
562562
563-
-Switch2 [<Boolean>]
563+
-Switch2 [<Boolean>] (-Switch2Alias)
564564
Switch2 description.
565565
566566
-Switch1 [<Boolean>]

‎src/Ookii.CommandLine.Tests/CommandLineParserTest.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -736,13 +736,13 @@ public void TestLongShortMode(ProviderKind kind)
736736
Assert.AreEqual(7, result.Arg2);
737737
Assert.AreEqual(8, result.Arg1);
738738
Assert.IsTrue(result.Switch1);
739-
Assert.IsFalse(result.Switch2);
739+
Assert.IsFalse(LongShortArguments.Switch2Value);
740740
Assert.IsFalse(result.Switch3);
741741

742742
// Combine switches.
743743
result = CheckSuccess(parser, new[] { "-su" });
744744
Assert.IsTrue(result.Switch1);
745-
Assert.IsFalse(result.Switch2);
745+
Assert.IsFalse(LongShortArguments.Switch2Value);
746746
Assert.IsTrue(result.Switch3);
747747

748748
// Use a short alias.

‎src/Ookii.CommandLine/AliasAttribute.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ namespace Ookii.CommandLine;
3838
/// <threadsafety static="true" instance="true"/>
3939
/// <seealso cref="CommandLineArgument.Aliases" qualifyHint="true"/>
4040
/// <seealso cref="Commands.CommandInfo.Aliases" qualifyHint="true"/>
41-
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.Class, AllowMultiple = true)]
41+
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = true)]
4242
public sealed class AliasAttribute : Attribute
4343
{
4444
private readonly string _alias;

‎src/Ookii.CommandLine/AllowDuplicateDictionaryKeysAttribute.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace Ookii.CommandLine;
2525
/// </remarks>
2626
/// <threadsafety static="true" instance="true"/>
2727
/// <seealso cref="DictionaryArgumentInfo.AllowDuplicateKeys" qualifyHint="true"/>
28-
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter)]
28+
[AttributeUsage(AttributeTargets.Property)]
2929
public sealed class AllowDuplicateDictionaryKeysAttribute : Attribute
3030
{
3131
}

‎src/Ookii.CommandLine/Conversion/KeyValueSeparatorAttribute.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace Ookii.CommandLine.Conversion;
1717
/// </para>
1818
/// </remarks>
1919
/// <threadsafety static="true" instance="true"/>
20-
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter)]
20+
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)]
2121
public class KeyValueSeparatorAttribute : Attribute
2222
{
2323
private readonly string _separator;

‎src/Ookii.CommandLine/MultiValueSeparatorAttribute.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ namespace Ookii.CommandLine;
4848
/// </para>
4949
/// </remarks>
5050
/// <threadsafety static="true" instance="true"/>
51-
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter)]
51+
[AttributeUsage(AttributeTargets.Property)]
5252
public class MultiValueSeparatorAttribute : Attribute
5353
{
5454
private readonly string? _separator;

‎src/Ookii.CommandLine/ShortAliasAttribute.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace Ookii.CommandLine;
3030
/// </para>
3131
/// </remarks>
3232
/// <threadsafety static="true" instance="true"/>
33-
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter, AllowMultiple = true)]
33+
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Method, AllowMultiple = true)]
3434
public sealed class ShortAliasAttribute : Attribute
3535
{
3636
private readonly char _alias;

‎src/Ookii.CommandLine/Validation/ArgumentValidationAttribute.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace Ookii.CommandLine.Validation;
2626
/// </para>
2727
/// </remarks>
2828
/// <threadsafety static="true" instance="true"/>
29-
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Method | AttributeTargets.Parameter)]
29+
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)]
3030
public abstract class ArgumentValidationAttribute : Attribute
3131
{
3232
/// <summary>

0 commit comments

Comments
 (0)
Please sign in to comment.