Skip to content

Commit

Permalink
fix: Fixed CLI issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed Jul 6, 2024
1 parent d8e4c4f commit d6ae550
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/libs/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
</ItemGroup>

<PropertyGroup Label="Versioning">
<Version>0.11.9</Version>
<Version>0.11.10</Version>
<MinVerMinimumMajorMinor>0.1</MinVerMinimumMajorMinor>
<MinVerTagPrefix>v</MinVerTagPrefix>
<MinVerDefaultPreReleaseIdentifiers>dev</MinVerDefaultPreReleaseIdentifiers>
Expand Down
12 changes: 4 additions & 8 deletions src/libs/OpenApiGenerator.Cli/Commands/GenerateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class GenerateCommand : Command
description: "Input file path");
var outputOption = new Option<string>(
aliases: ["--output", "-o"],
getDefaultValue: () => string.Empty,
getDefaultValue: () => "Generated",
description: "Output file path");
var targetFrameworkOption = new Option<string>(
aliases: ["--targetFramework", "-t"],
Expand Down Expand Up @@ -83,7 +83,7 @@ private static async Task HandleAsync(
JsonSerializerType: default,
UseRequiredKeyword: default,
GenerateConstructors: false,
GroupByTags: false,
GroupByTags: true,
GenerateMethods: false,
MethodNamingConvention: default,
MethodNamingConventionFallback: MethodNamingConvention.MethodAndPath,
Expand Down Expand Up @@ -117,19 +117,15 @@ private static async Task HandleAsync(
.Where(x => !x.IsEmpty)
.ToArray();

Directory.CreateDirectory(outputPath);

if (generateAsSingleFile)
{
var text = string.Join(Environment.NewLine, files.Select(x => x.Text));
await File.WriteAllTextAsync(Path.Combine(outputPath, $"{name}.cs"), text).ConfigureAwait(false);
return;
}

if (string.IsNullOrWhiteSpace(outputPath))
{
outputPath = name;
Directory.CreateDirectory(outputPath);
}

foreach (var file in files)
{
await File.WriteAllTextAsync(Path.Combine(outputPath, file.Name), file.Text).ConfigureAwait(false);
Expand Down

0 comments on commit d6ae550

Please sign in to comment.