sqlflow_public/api/csharp/SQLFlowClient/Program.cs

74 lines
2.7 KiB
C#

using System;
using CommandLine;
using CommandLine.Text;
namespace SQLFlowClient
{
public class Options
{
[Value(0, MetaName = "sqlfile", Required = false, HelpText = "Input sqlfile to be processed.")]
public string SQLFile { get; set; }
[Option('g', "graph", Required = false, Default = false, HelpText = "Get the graph from sql.")]
public bool IsGraph { get; set; }
[Option('v', "dbvendor", Required = false, Default = "oracle", HelpText = "Set the database of the sqlfile.")]
public string DBVendor { get; set; }
[Option('r', "showRelationType", Required = false, Default = "fdd", HelpText = "Set the relation type.")]
public string ShowRelationType { get; set; }
[Option('s', "simpleOutput", Required = false, Default = false, HelpText = "Set whether to get simple output.")]
public bool SimpleOutput { get; set; }
[Option("ignoreRecordSet", Required = false, Default = false, HelpText = "Set whether to ignore record set.")]
public bool IgnoreRecordSet { get; set; }
[Option("ignoreFunction", Required = false, Default = false, HelpText = "Set whether to ignore function.")]
public bool ignoreFunction { get; set; }
[Option('o', "output", Required = false, Default = "", HelpText = "Save output as a file.")]
public string Output { get; set; }
//[Option('t', "token", Required = false, Default = "", HelpText = "If userId and secretKey is given, token will be ignore, otherwise it will use token.")]
//public string Token { get; set; }
//[Option('u', "userId", Required = false, Default = "", HelpText = "")]
//public string UserId { get; set; }
//[Option('k', "secretKey", Required = false, Default = "", HelpText = "")]
//public string SecretKey { get; set; }
[Option("version", Required = false, Default = false, HelpText = "Show version.")]
public bool Version { get; set; }
}
class Program
{
static void Main(string[] args)
{
var parser = new Parser(with =>
{
with.AutoVersion = false;
with.AutoHelp = true;
});
var parserResult = parser.ParseArguments<Options>(args); ;
parserResult
.WithParsed(options =>
{
HttpService.Request(options).Wait();
})
.WithNotParsed(errs =>
{
var helpText = HelpText.AutoBuild(parserResult, h =>
{
h.AutoHelp = true;
h.AutoVersion = false;
return h;
}, e => e);
Console.WriteLine(helpText);
});
}
}
}