Git Product home page Git Product logo

Comments (8)

kdeldycke avatar kdeldycke commented on June 4, 2024 1

You can change the default parameters from @extra_command with the params= argument. This is referenced in the documentation at: https://kdeldycke.github.io/click-extra/commands.html#change-default-options

So this should work for you:

from click_extra import extra_command

@extra_command(params=[])
def cli():
   pass

Now considering your question, maybe I should add an explicit explanation in the docs for that particular case of stripping all default options.

from click-extra.

kdeldycke avatar kdeldycke commented on June 4, 2024 1

I finally addressed that need in ac275b5.

It was way more complicated that I anticipated, but it simplifies a lot this use-case.

Now to disable all default parameters from extra commands while keeping the coloring, you can do:

from click_extra import extra_command

@extra_command(params=None)
def cli():
   pass

I'll document this soon and it will be available in the upcoming release of Click Extra v4.6.0.

from click-extra.

isezen avatar isezen commented on June 4, 2024

Thank you very much. I read all the docs but there was not a clear explanation. I had found a way but your solution is more clear and easy.

from click-extra.

isezen avatar isezen commented on June 4, 2024

I just tried your solution but it does not colorize the help output. :(

I created my_click_extra.py file with following content and If I use following group decorator by importing, then it works.

import cloup as _cloup
import click_extra as _ce

def _extra_params():
    return [
        _ce.colorize.HelpOption(),
    ]

group = _ce.decorators.decorator_factory(
    dec=_cloup.group,
    cls=_ce.commands.ExtraGroup,
    params=_extra_params,
)

from click-extra.

kdeldycke avatar kdeldycke commented on June 4, 2024

Thanks @isezen for the code example.

So yes you are right, the solution I proposed earlier could not work. I just realized that most of the color-related behavior are implemented in Click Extra's --help and --no-color custom options.

I need to think about how to make your use-case easy. Something like creating another set of decorators, like @colored_command() and @colored_group(), which would be like @extra_command and @extra_group, but with the minimal options to make the output coloured.

I'll put that in the backburner as I have other things to stabilize in Click Extra before I can cut a release. But if you feel like creating a PR for that, I'll be happy to merge it upstream! :)

from click-extra.

isezen avatar isezen commented on June 4, 2024

Thank you for encouraging me to be included in the project :) You are very kind. I created a PR for your approval. I'm studying click_extra, cloup and click code, I hope I can contribute more in the future. Thank you very much for your work.

from click-extra.

kdeldycke avatar kdeldycke commented on June 4, 2024

For the record, new colour-preserving decorators were proposed at: #543

from click-extra.

github-actions avatar github-actions commented on June 4, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

from click-extra.

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.