Skip to content

Commit 0db9c8a

Browse files
committed
Add trailing slash for -o
1 parent 429f584 commit 0db9c8a

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/Cli/Microsoft.TemplateEngine.Cli/Commands/SharedOptions.cs

+18-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System.CommandLine;
5+
using System.CommandLine.Parsing;
56

67
namespace Microsoft.TemplateEngine.Cli.Commands
78
{
@@ -11,7 +12,23 @@ public static class SharedOptions
1112
{
1213
Description = SymbolStrings.Option_Output,
1314
Required = false,
14-
Arity = new ArgumentArity(1, 1)
15+
Arity = new ArgumentArity(1, 1),
16+
CustomParser = (ArgumentResult argumentResult) =>
17+
{
18+
var input = argumentResult.Tokens[0]?.Value;
19+
if (string.IsNullOrWhiteSpace(input))
20+
{
21+
return null;
22+
}
23+
else if (Path.EndsInDirectorySeparator(input))
24+
{
25+
return new FileInfo(input);
26+
}
27+
else
28+
{
29+
return new FileInfo(input + Path.DirectorySeparatorChar);
30+
}
31+
}
1532
};
1633

1734
public static Option<FileInfo> ProjectPathOption { get; } = new Option<FileInfo>("--project")

0 commit comments

Comments
 (0)