Giter Site home page Giter Site logo

Is click too verbose in its api? about click HOT 2 CLOSED

pallets avatar pallets commented on July 23, 2024
Is click too verbose in its api?

from click.

Comments (2)

mitsuhiko avatar mitsuhiko commented on July 23, 2024

The decorators themselves don't do much besides creating Argument or Option instances. So while you could potentially split up the interface into flags, options, arguments, counters and whatnot it would not make sense to split the lower level class up because there really is not that much stuff in there that can be clearly isolated.

As an example do options become flags by various modes. For instance option('--foo/--bar') automatically makes something into a flag, same with option('--foo', flag_value='whatever').

Counters can't become a separate decorator easily either because a counter still accepts all the other behaviors of an option (sans counter). For instance you can set a default or change the type from an integer to a integer range etc.

The only thing you would gain at the end of the day is to make the edge case @click.option('--x', is_flag=True) (which is strongly discouraged!) to @click.flag('-x'). I'm not sure I like that.

But more than anything, once you go down that road you now have the problem that certain behavior is restricted to options whereas it would otherwise also work for arguments. In case of flags here is no reason why at one point we might not find a use for exposing them to arguments as well.

It's not really possible to "create decorators" that hold this functionality because the decorators don't actually do anything. The underlying class does, and that class does multiple things at once and is not clearly cut and separated.

from click.

cessor avatar cessor commented on July 23, 2024

Thank you for your clarification. I will spend some time with the source code before answering.

from click.

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.