-
Notifications
You must be signed in to change notification settings - Fork 331
Expand file tree
/
Copy pathValidateOptions.cs
More file actions
47 lines (42 loc) · 1.49 KB
/
ValidateOptions.cs
File metadata and controls
47 lines (42 loc) · 1.49 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
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System.IO.Abstractions;
using Azure.DataApiBuilder.Config;
using Azure.DataApiBuilder.Product;
using Azure.DataApiBuilder.Service;
using Cli.Constants;
using CommandLine;
using Microsoft.Extensions.Logging;
using static Cli.Utils;
namespace Cli.Commands
{
/// <summary>
/// Validate command options
/// </summary>
[Verb("validate", isDefault: false, HelpText = "Validate config for Data Api Builder Engine", Hidden = false)]
public class ValidateOptions : Options
{
public ValidateOptions(string config)
: base(config)
{ }
/// <summary>
/// This Handler method is responsible for validating the config file and is called when `validate`
/// command is invoked.
/// </summary>
public int Handler(ILogger logger, FileSystemRuntimeConfigLoader loader, IFileSystem fileSystem)
{
logger.LogInformation("{productName} {version}", PRODUCT_NAME, ProductInfo.GetProductVersion());
Startup.AddValidFilters();
bool isValidConfig = ConfigGenerator.IsConfigValid(this, loader, fileSystem);
if (isValidConfig)
{
logger.LogInformation("Config is valid.");
}
else
{
logger.LogError("Config is invalid.");
}
return isValidConfig ? CliReturnCode.SUCCESS : CliReturnCode.GENERAL_ERROR;
}
}
}