Git Product home page Git Product logo

Comments (3)

nlappas avatar nlappas commented on June 8, 2024

You can always handle it in your code

int logLvl = 0;   // Off by default
if(args["log"]) {
   logLvl = 3;   // Enable default level
   if(args["log"].as<std::string>()=="errors-only") logLvl = 1;  // Use custom
}

from argagg.

vietjtnguyen avatar vietjtnguyen commented on June 8, 2024

Yea, my concern with having that style of optional argument is that it actually introduces a third state to the flag. Also, it messes with the current greedy argument behavior. For example, foo --log --verbose would make --verbose an argument to --log.

  • 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.

from argagg.

vietjtnguyen avatar vietjtnguyen commented on June 8, 2024

I'm going to close this for now though I'm open to further discussion in this issue.

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.