You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a command is not present, I should be able to reference it in the dictionary and use .IsNullOrEmpty to check for it's present. But it throws System.NullReferenceException instead.
In my case, I did not mark as optional. I used the version where I gave 2 example command lines, each with a different COMMAND perhaps that's the issue?
There is a workaround below, but I would have thought you were populate a default Object in the dictionary so that the IsNullOrEmpty could be used.
Snippet of syntax below.
[TestMethod]
public void Test_CommandLine()
{
const string USAGE = @"prog.
Usage: prog PREPARE (--folderpath <path> | --azure --jobid <jobid> --simrun <simrun> --token <token> --host <host>)
prog SIMIULATE --scenario <scenario_name> (--folderpath <path> | --azure --simrun <simrun> --token <token> --host <host>)";
var opt = new Docopt();
var arguments = opt.Apply(USAGE, "simulate --scenario senario1 --azure --simrun simrun --token token --host host");
//This would crash
if(arguments["PREPARE"].IsNullOrEmpty)
{
}
//So would have to do this instead.
if (arguments["PREPARE"] != null)
{
}
}
The text was updated successfully, but these errors were encountered:
When a command is not present, I should be able to reference it in the dictionary and use .IsNullOrEmpty to check for it's present. But it throws System.NullReferenceException instead.
In my case, I did not mark as optional. I used the version where I gave 2 example command lines, each with a different COMMAND perhaps that's the issue?
There is a workaround below, but I would have thought you were populate a default Object in the dictionary so that the IsNullOrEmpty could be used.
Snippet of syntax below.
[TestMethod]
public void Test_CommandLine()
{
const string USAGE = @"prog.
The text was updated successfully, but these errors were encountered: