Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two consecutive Arrays causes second one not to be read #6

Closed
m1gu3l opened this issue Jun 29, 2012 · 4 comments
Closed

Two consecutive Arrays causes second one not to be read #6

m1gu3l opened this issue Jun 29, 2012 · 4 comments

Comments

@m1gu3l
Copy link

m1gu3l commented Jun 29, 2012

    [Option("s", "source", Required = true, HelpText = "Source Word2007+ document path")]
    public string SourceDocument { get; set; }

    [Option("o", "output", Required = true, HelpText = "Output Excel2007+ spreadsheet path")]
    public string OutputSpreadsheet { get; set; }

    [OptionArray("h", "headers", Required = true, HelpText = "List of coords to cells with headers")]
    public uint[] Headers { get; set; }

    [OptionArray("c", "content", Required = true, HelpText = "List of coords to cells with content")]
    public uint[] Content { get; set; }

    [Option("v", "verbose", Required = false, DefaultValue = false, HelpText = "Print details during execution")]
    public bool Verbose { get; set; }

app.exe --source d:/document.docx --output d:/document.xlsx --headers 0 1 1 1 --content 0 2 1 2 --verbose

.NET 4.0, Windows 7, C# Express 2010

@gsscoder
Copy link
Owner

Received. Thanks for reporting! I'll check ASAP...
Giacomo

@gsscoder
Copy link
Owner

Hi, in my first investigation it seems that the problem can be avoided forcing the use of option with just short name when mapped as OptionArray.
Try launch your app as:

app.exe --source d:/document.docx --output d:/document.xlsx -h 0 1 1 1 -c 0 2 1 2 --verbose

In this case for consistency you should remove long name from option definition to avoid confusion.

Warning, this is just a workaround! Not the final solution.

Summer heat allowing :D , I'll try to write some new unit tests for isolate this issue and finally solve it!
Every progress will be posted here and source code will be updated.

Regards,
Giacomo

@gsscoder
Copy link
Owner

@m1gu3l I'm writing a new unit test that should definitely solve the problem.

Thank :D for your infinite patient!

Also forgive for not trying merging PR, I was accustomed to use SVN in my internal organization and getting really familiar with Git/GitHub just in these last times.

I really appreciate any help and please never see a bad intention when some PR is not merged, a reply is not given soon or similar things... :)

gsscoder added a commit that referenced this issue Feb 21, 2013
@gsscoder
Copy link
Owner

// Given
var options = new OptionsWithTwoArrays();
var parser = new Parser();
var argumets = new[] { "--source", @"d:/document.docx", "--output", @"d:/document.xlsx",
        "--headers", "1", "2", "3", "4",  // first array
        "--content", "5", "6", "7", "8",  // second array
        "--verbose"
    };

// When
var result = parser.ParseArguments(argumets, options);

// Than
result.Should().BeTrue();
options.Headers.Should().HaveCount(c => c == 4);
options.Headers.Should().ContainInOrder(new uint[] { 1, 2, 3, 4 });
options.Content.Should().HaveCount(c => c == 4);
options.Content.Should().ContainInOrder(new uint[] { 5, 6, 7, 8 });

If possible, please provide feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants