Coder Social home page Coder Social logo

Support for default verb? about commandline HOT 7 OPEN

alexreg avatar alexreg commented on August 15, 2024
Support for default verb?

from commandline.

Comments (7)

alexreg avatar alexreg commented on August 15, 2024

Furthermore, is it possible to have global options while still having a verb?

from commandline.

nemec avatar nemec commented on August 15, 2024

This is a duplicate of #490. Unfortunately, no it isn't possible. With the way verbs work in the current version (e.g. Parse<VerbA, VerbB>(args)) I'm having a hard time thinking of a way to add a default verb and global options.

from commandline.

alexreg avatar alexreg commented on August 15, 2024

Thanks for the quick reply, @nemec. What about a simple IsDefault property of the Verb attribute. The name of the verb should also be optional in this case. As for global options, what about a special Options generic argument that inherits from a (dummy) GlobalOptions class, or something similar?

Update: Actually, quite a nice solution that already works is simply inheriting from a GlobalOptions class!

from commandline.

alexreg avatar alexreg commented on August 15, 2024

I'm currently trying to come up with a workaround for this, but I can't get the NoVerbSelectedError, nor the BadVerbSelectedError. It just runs my (one and only) options handler instead. Using the latest beta here. Any known issue with that right now?

from commandline.

alexreg avatar alexreg commented on August 15, 2024

Update: it seems I have to specify at least two options types to ParseArguments for these errors to kick in! I see why, though perhaps this should be documented.

from commandline.

nemec avatar nemec commented on August 15, 2024

You're right - it is not obvious that one generic argument is interpreted as an Options class but multiple are considered Verbs.

from commandline.

TheFanatr avatar TheFanatr commented on August 15, 2024

Just to clarify, is there a workaround by using GlobalOptions?

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.