Repository navigation
Expand file tree
/
Copy pathProgram.cs
More file actions
60 lines (50 loc) · 2.54 KB
/
Copy pathProgram.cs
File metadata and controls
60 lines (50 loc) · 2.54 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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
using System.CommandLine;
using System.Threading.Tasks;
using Microsoft.OpenApi.Hidi.Handlers;
using Microsoft.OpenApi.Hidi.Options;
using Microsoft.OpenApi.Hidi.Extensions;
namespace Microsoft.OpenApi.Hidi
{
static class Program
{
static Task<int> Main(string[] args)
{
var rootCommand = CreateRootCommand();
// Parse the incoming args and invoke the handler
var parseResult = rootCommand.Parse(args);
return parseResult.InvokeAsync();
}
internal static RootCommand CreateRootCommand()
{
var rootCommand = new RootCommand { };
var commandOptions = new CommandOptions();
var validateCommand = new Command("validate");
validateCommand.Description = "Validate an OpenAPI document.";
validateCommand.AddOptions(commandOptions.GetValidateCommandOptions());
var validateCommandHandler = new ValidateCommandHandler(commandOptions);
validateCommand.SetAction(validateCommandHandler.InvokeAsync);
var transformCommand = new Command("transform");
transformCommand.Description = "Transform an OpenAPI or CSDL document into a JSON/YAML OpenAPI v2/v3 document.";
transformCommand.AddOptions(commandOptions.GetAllCommandOptions());
var transformCommandHandler = new TransformCommandHandler(commandOptions);
transformCommand.SetAction(transformCommandHandler.InvokeAsync);
var showCommand = new Command("show");
showCommand.Description = "Create a visual representation of the paths in an OpenAPI document.";
showCommand.AddOptions(commandOptions.GetShowCommandOptions());
var showCommandHandler = new ShowCommandHandler(commandOptions);
showCommand.SetAction(showCommandHandler.InvokeAsync);
var pluginCommand = new Command("plugin");
pluginCommand.Description = "Create manifest files for an OpenAI plugin [preview]";
pluginCommand.AddOptions(commandOptions.GetPluginCommandOptions());
var pluginCommandHandler = new PluginCommandHandler(commandOptions);
pluginCommand.SetAction(pluginCommandHandler.InvokeAsync);
rootCommand.Add(showCommand);
rootCommand.Add(transformCommand);
rootCommand.Add(validateCommand);
rootCommand.Add(pluginCommand);
return rootCommand;
}
}
}