Git Product home page Git Product logo

Comments (4)

vietjtnguyen avatar vietjtnguyen commented on May 30, 2024

This is actually intended behavior and has been brought up before in #16. Here's an edit of my response:

Yea, my concern with having that style of optional argument is that it actually introduces a third state to the flag.

  • flag not specified
  • flag specified followed by non-flag
  • flag specified followed by a flag (and thus specified without argument)

Currently a flag has two states:

  • flag not specified
  • flag specified with argument

I feel like if there's some default behavior you want with a flag specified with no argument it can be captured by its own flag. Consider git log for example, --oneline is equivalent to --pretty=oneline.

Also, it messes with the current greedy argument behavior. For example, foo --log --verbose would make --verbose an argument to --log.

I'm open to further discussion on this though.

from argagg.

raptor avatar raptor commented on May 30, 2024

Hi,

I read that issue, and agree with your assessment; however, the --def-opt flag still does not work as stated on the main page readme:

If you want to get an option argument but fallback on a default value if it doesn't exist then you can use the argagg::option_results::as() API and provide a default value

When the value doesn't exist, I actually get that error described in my opening post. Am I misunderstanding this?

Thanks

from argagg.

vietjtnguyen avatar vietjtnguyen commented on May 30, 2024

I see, the wording in my README is poor then. I think it is more precisely worded as:

If you want to get an option argument but fallback on a default value if the option is not specified then you can use the argagg::option_results::as() API and provide a default value.

For the sample, I added some unit test cases that hopefully clarify the behavior:

Let me know if that clarifies the behavior or not.

from argagg.

raptor avatar raptor commented on May 30, 2024

Ah OK, I understand better now. Thanks for the clarification.

from argagg.

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.