Code Monkey home page Code Monkey logo

Comments (7)

alexanderfast avatar alexanderfast commented on July 17, 2024

It works if I add this constructor:

public MyVerbs()
{
    Foo = new FooOptions();
}

However, I was hoping to be able to use the convention of "only one options-property will be non-null, and its corresponding run method should be invoked".

Do you have any suggestions how to determine which "verb logic" should be run? Manually check the first string in args?

from commandline.

gsscoder avatar gsscoder commented on July 17, 2024

I was working on the subject on this moments... (committed less than one minute!)
I've made a little fix, so check if it solved.

For now, in the principle of developer freedom, I've used a property-base verb design. This allow more freed, as said, about instance management penalizing a little elegance :(.

So check the last wiki (updated this moment). For now you've to check manually:

if (CommandLineParser.Default.WasVerbOptionInvoked("foo")) {
  // app foo --options invoked
} else if(CommandLineParser.Default.WasVerbOptionInvoked("bar")) {
  // app bar --options invoked
}

I remember your suggestion of a method-based design and I'm going to add this to the default way. After all, this library always used reflection, "weak contracts" and more paths to get thing done.

// this will remain valid
[VerbOption("commit", HelpText = "Record changes to the repository.")]
public CommitSubOptions CommitVerb { get; set; }

// along with
[VerbOption("commit", HelpText = "Record changes to the repository.")]
public CommitVerb(CommitSubOptions subOptions)
{
  // do stuff here
}

Backing to your sample, give me some time. I'll check it and reply here. Thanks for reporting!

from commandline.

alexanderfast avatar alexanderfast commented on July 17, 2024

Also check pull request #46, it uses the Activator to create an instance if (and only if) the developer hasn't assigned a non-null value to the options property.

WasVerbOptionInvoked looks good enough to me, I'll use that to wire verbs to methods, thanks!

from commandline.

gsscoder avatar gsscoder commented on July 17, 2024

Thank to you!
The problem is clear...

When you request help, the instance is still not created. Simply a bug that must be fixed!

But it is simple, I think... I'll back soon.

from commandline.

alexanderfast avatar alexanderfast commented on July 17, 2024

Any feedback on the pull request? :) Was I way off?

from commandline.

gsscoder avatar gsscoder commented on July 17, 2024

Thanks. After the last comment I switched to fixing. I see now that the pull solve this issue too!

I've fixed before the call occur. It is essentially the same; the problem is that this "case" escaped also from unit test... (I've to start using PEX also for this project!).

Please give a try and if it works, we can close the issue.

from commandline.

alexanderfast avatar alexanderfast commented on July 17, 2024

It works, closing.

from commandline.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.