I am using the CommandLineParser and literally pasting the example code into my example project. I get alot of errors such as:
Severity Code Description Project File Line Suppression State Error CS0246 The type or namespace name 'DefaultValue' could not be found (are you missing a using directive or an assembly reference?)
Severity Code Description Project File Line Suppression State Error CS0246 The type or namespace name 'ParserStateAttribute' could not be found (are you missing a using directive or an assembly reference?)
Am I not including a library or something? I have included CommandLine
and I have installed the package via nuget https://archive.codeplex.com/?p=commandline
.
using System;
using CommandLine;
namespace Foo
{
class Program
{
class Options
{
[Option('r', "read", Required = true,
HelpText = "Input file to be processed.")]
public string InputFile { get; set; }
[Option('v', "verbose", DefaultValue = true,
HelpText = "Prints all messages to standard output.")]
public bool Verbose { get; set; }
[ParserState]
public IParserState LastParserState { get; set; }
[HelpOption]
public string GetUsage()
{
return HelpText.AutoBuild(this,
(HelpText current) => HelpText.DefaultParsingErrorsHandler(this, current));
}
}
static void Main(string[] args)
{
var options = new Options();
if (CommandLine.Parser.Default.ParseArguments(args, options))
{
// Values are available here
if (options.Verbose) Console.WriteLine("Filename: {0}", options.InputFile);
}
}
}
}