Skip to content

Commit

Permalink
fix: support the Description field of VersionOptionFromMemberAttribute (
Browse files Browse the repository at this point in the history
  • Loading branch information
kopytk0 authored Jan 30, 2022
1 parent e81e13b commit 3352423
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ internal CommandOption Configure(CommandLineApplication app, Type type, Func<obj
};
}

return app.VersionOption(Template, shortFormGetter, longFormGetter);
var option = app.VersionOption(Template, shortFormGetter, longFormGetter);
Configure(option);
return option;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Linq;
using Xunit;

namespace McMaster.Extensions.CommandLineUtils.Tests
Expand Down Expand Up @@ -67,5 +68,19 @@ public void ThrowWhenMemberDoesNotExist()
});
Assert.Equal(Strings.NoPropertyOrMethodFound("Version", typeof(MissingMethod)), ex.Message);
}

[VersionOptionFromMember(Description = "42")]
private class Description
{
}

[Fact]
public void GetsDescriptionFromOption()
{
var app = new CommandLineApplication<Description>();
app.Conventions.UseVersionOptionFromMemberAttribute();

Assert.Equal("42", app.Options.First().Description);
}
}
}

0 comments on commit 3352423

Please sign in to comment.