Git Product home page Git Product logo

Comments (6)

evanunderscore avatar evanunderscore commented on June 23, 2024

I think I initially had reasons for not doing this but they all seem a bit weak now. I like the idea of doing this automatically.

I personally find negations using + to be counter-intuitive, but I'm aware that they're used in a number of places, so I'm not against giving people the option to use them if we can find a simple way of doing it. I'll keep this in mind when looking at #2.

from defopt.

flying-sheep avatar flying-sheep commented on June 23, 2024

an alternative would be negations using the uppercase short opt.

from defopt.

evanunderscore avatar evanunderscore commented on June 23, 2024

What's the point of the inverted flags? I know they're used in some places, but they just seem confusing to me. Here's an actual example from pip install -h:

  --compile                   Compile py files to pyc
  --no-compile                Do not compile py files to pyc

Obviously one of these must be the default, but I have no way of telling. Since one of them is implied by not specifying it, why do we need the flag at all?

Here's another flag for the same command:

--no-clean                  Don't clean up build directories.

Since there is no corresponding --clean flag, I know that the default behavior must be to clean up build directories.

from defopt.

flying-sheep avatar flying-sheep commented on June 23, 2024

with both, the default can be changed anytime (--flag means True, --no-flag means False)

and as the later option trumps, you can override stuff in aliases, …

alias ls='ls -l'
$ ls
drwxr-xr-x 1 phil users  314  6. Mär 12:12 bin/
$ ls -x
bin/

from defopt.

evanunderscore avatar evanunderscore commented on June 23, 2024

I've had a shot at an implementation of this to use as a discussion point. Take a look at 09bdead.

Some points to discuss:

  • This only applies to optional arguments; a positional boolean argument is still specified as something accepted by _parse_bool.
  • The help message only shows documentation for the --name flag; the --no-name flag is blank but comes immediately after the other flag so should be clear enough.
  • This allows for you to have None or some other value as the default, so neither --name nor --no-name are necessarily implied to match the default behavior (if you really want to do that).

from defopt.

evanunderscore avatar evanunderscore commented on June 23, 2024

This has been implemented and will be in 2.0. Discussion on how to handle short flags can continue in #2 if necessary.

from defopt.

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.