```c#
using CommandLine;
using System;
using System.Windows.Forms;
namespace MWR_Config_Editor
{
static class Program
{
private static readonly NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger();
public static Options Arguments;
public class Options
{
[Option('c', "console", Required = false, HelpText = "Enable console")]
public bool Verbose { get; set; }
}
///
/// The main entry point for the application.
///
[STAThread]
static void Main(string[] args)
{
Logger.Debug("Program started");
Arguments = Parser.Default.ParseArguments
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Main());
Logger.Debug("Program ended");
}
}
}
```
modify:
public static Options Arguments;
to
public static ParserResult<Options> Arguments;
And how am i supposed to access the variables inside it then? ParserResult does not contain a instance of Options
You need to use WithParsed, something like:
Parser.Default.ParseArguments<Options>(args).WithParsed(result => Arguments = result);
The [Pr #634) exposes The Parsed option Value to the base class, available in develop branch and will be released in v2.9.
You can:
var result = Parser.Default.ParseArguments<Options>(args);
Arguments = result.Value;
Thanks :)
Most helpful comment
The [Pr #634) exposes The Parsed option Value to the base class, available in develop branch and will be released in v2.9.
You can: