-
Notifications
You must be signed in to change notification settings - Fork 275
Expand file tree
/
Copy pathHidiOptions.cs
More file actions
65 lines (60 loc) · 3.3 KB
/
HidiOptions.cs
File metadata and controls
65 lines (60 loc) · 3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
using System.CommandLine.Parsing;
using System.IO;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.OpenApi.Hidi.Utilities;
namespace Microsoft.OpenApi.Hidi.Options
{
internal class HidiOptions
{
private const string defaultOutputFolderValue = "./";
public string? OpenApi { get; set; }
public string? Csdl { get; set; }
public string? CsdlFilter { get; set; }
public FileInfo? Output { get; set; }
public string OutputFolder { get; set; } = defaultOutputFolderValue;
public bool CleanOutput { get; set; }
public string? Version { get; set; }
public string? MetadataVersion { get; set; }
public string? OpenApiFormat { get; set; }
public bool TerseOutput { get; set; }
public IConfiguration? SettingsConfig { get; set; }
public LogLevel LogLevel { get; set; }
public bool InlineLocal { get; set; }
public bool InlineExternal { get; set; }
public FilterOptions FilterOptions { get; set; } = new();
public HidiOptions(ParseResult parseResult, CommandOptions options)
{
ParseHidiOptions(parseResult, options);
}
public HidiOptions()
{
}
private void ParseHidiOptions(ParseResult parseResult, CommandOptions options)
{
OpenApi = parseResult.GetValueForOption(options.OpenApiDescriptionOption);
CsdlFilter = parseResult.GetValueForOption(options.CsdlFilterOption);
Csdl = parseResult.GetValueForOption(options.CsdlOption);
Output = parseResult.GetValueForOption(options.OutputOption);
OutputFolder = parseResult.GetValueForOption(options.OutputFolderOption) is string outputFolderOptionValue && !string.IsNullOrEmpty(outputFolderOptionValue) ? outputFolderOptionValue : defaultOutputFolderValue;
CleanOutput = parseResult.GetValueForOption(options.CleanOutputOption);
Version = parseResult.GetValueForOption(options.VersionOption);
MetadataVersion = parseResult.GetValueForOption(options.MetadataVersionOption);
OpenApiFormat = parseResult.GetValueForOption(options.FormatOption);
TerseOutput = parseResult.GetValueForOption(options.TerseOutputOption);
SettingsConfig = parseResult.GetValueForOption(options.SettingsFileOption) is string configOptionValue && !string.IsNullOrEmpty(configOptionValue) ? SettingsUtilities.GetConfiguration(configOptionValue) : null;
LogLevel = parseResult.GetValueForOption(options.LogLevelOption);
InlineLocal = parseResult.GetValueForOption(options.InlineLocalOption);
InlineExternal = parseResult.GetValueForOption(options.InlineExternalOption);
FilterOptions = new()
{
FilterByOperationIds = parseResult.GetValueForOption(options.FilterByOperationIdsOption),
FilterByTags = parseResult.GetValueForOption(options.FilterByTagsOption),
FilterByCollection = parseResult.GetValueForOption(options.FilterByCollectionOption),
FilterByApiManifest = parseResult.GetValueForOption(options.ManifestOption)
};
}
}
}