CommandLineParser
(Command Line Parser Library에서 넘어옴)
https://github.com/commandlineparser/commandline
C:\Project> Nuget Install CommandLineParser
샘플소스[편집 | 원본 편집]
using CommandLine;
using System;
using System.Data;
using System.IO;
using System.Linq;
namespace refNotifier
{
public class Options
{
[Option('f', "file", Required = true, HelpText = "데이터 파일을 지정합니다.")]
public string FilePath { get; set; }
[Option('i', "min", Required = false, HelpText = "최소값을 지정합니다.")]
public decimal Min { get; set; }
[Option('a', "max", Required = false, HelpText = "최대값을 지정합니다.")]
public decimal Max { get; set; }
[Option('v', "verbose", Required = false, HelpText = "Set output to verbose messages.")]
public bool Verbose { get; set; }
}
class Program
{
static void Main(string[] args)
{
Parser.Default.ParseArguments<Options>(args)
.WithParsed<Options>(o =>
{
if (o.Verbose)
{
Console.WriteLine($"Verbose output enabled. Current Arguments: -v {o.Verbose}");
Console.WriteLine("Quick Start Example! App is in Verbose mode!");
}
else
{
Console.WriteLine($"Current Arguments: -v {o.Verbose}");
Console.WriteLine("Quick Start Example!");
}
});
}
}
}