Git Product home page Git Product logo

Comments (4)

evanunderscore avatar evanunderscore commented on July 28, 2024

I like this idea. I didn't do it originally because I didn't want adding a parameter to be able to break backwards compatibility. For example, if you later come and add baz, you'll lose the -b. I think if we do this it should be opt-in. Also note that you already get the default argparse behavior of allowing unambiguous shortened flags, e.g. --f and --fo.

Would you like to work on a PR?

from defopt.

anntzer avatar anntzer commented on July 28, 2024

I don't think(?) shortened long flags can be stacked as --abc (for --a --b --c).

This feature doesn't necessarily break backcompatibility as you can apparently just pass whatever short flags you want to defopt.run (although an example is actually missing at http://defopt.readthedocs.io/en/latest/examples.html#module-examples.short). So if someone wants to add a second option with the same initial, they has the choice of whether to break backcompat, or just disambiguate things themselves.

No time for a PR right now...

from defopt.

evanunderscore avatar evanunderscore commented on July 28, 2024

No, the shortened long flags won't stack.

My concern is not that the feature itself will break backwards compatibility, rather that having it enabled by default will create a gotcha where a developer can remove a flag without realizing. The tools will still be there to restore the short flag once they notice. I don't know whether this is a strong enough argument for having it off by default, though.

from defopt.

anntzer avatar anntzer commented on July 28, 2024

If you really want to play extra safe, you could issue a warning whenever multiple short flags conflict (with an option to disable it). But that would break backcompatibility of defopt.

I don't think the backcompatibility issue on the user side is that big, even if the dev does no testing -- at worst, what happens is that someone was using a short flag, sees that it doesn't work anymore, complains to the dev, who realizes the issue and resolves it manually. It's never going to run an incorrect command, at least.

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.