mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-10 17:28:27 -04:00
Global usings and file scoped namespaces
This commit is contained in:
@@ -1,24 +1,23 @@
|
||||
using CommandLine;
|
||||
|
||||
namespace NadekoBot.Common
|
||||
{
|
||||
public static class OptionsParser
|
||||
{
|
||||
public static T ParseFrom<T>(string[] args) where T : INadekoCommandOptions, new()
|
||||
=> ParseFrom(new T(), args).Item1;
|
||||
namespace NadekoBot.Common;
|
||||
|
||||
public static (T, bool) ParseFrom<T>(T options, string[] args) where T : INadekoCommandOptions
|
||||
public static class OptionsParser
|
||||
{
|
||||
public static T ParseFrom<T>(string[] args) where T : INadekoCommandOptions, new()
|
||||
=> ParseFrom(new T(), args).Item1;
|
||||
|
||||
public static (T, bool) ParseFrom<T>(T options, string[] args) where T : INadekoCommandOptions
|
||||
{
|
||||
using (var p = new Parser(x =>
|
||||
{
|
||||
x.HelpWriter = null;
|
||||
}))
|
||||
{
|
||||
using (var p = new Parser(x =>
|
||||
{
|
||||
x.HelpWriter = null;
|
||||
}))
|
||||
{
|
||||
var res = p.ParseArguments<T>(args);
|
||||
options = res.MapResult(x => x, x => options);
|
||||
options.NormalizeOptions();
|
||||
return (options, res.Tag == ParserResultType.Parsed);
|
||||
}
|
||||
var res = p.ParseArguments<T>(args);
|
||||
options = res.MapResult(x => x, x => options);
|
||||
options.NormalizeOptions();
|
||||
return (options, res.Tag == ParserResultType.Parsed);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user