Code Monkey home page Code Monkey logo

click-help-colors's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

click-help-colors's Issues

Colorize version_option

I want to improve how version is displayed by adding some coloring around the version number like green if is latest, red if is outdated or magenta if is unreleased.

Currently using just click I get something like:

molecule, version 3.0a6.dev40+gc589b240.d20200202

How can I make use of click-help-colors in order to improve the version printing?

PS. I know I can DIY, but this seems like a cool feature to have it supported and documented.

Highlighting of options, choices and metavars

I developed some code in my mail-deduplicate CLI some month ago to automatically highlights all options, choices and metavars in help screens generated by click. See how it renders:

cli-colored-help

For reference, here is my current implementation, which is mainly based on regular expressions.

To me it is a good enough compromise, because help screen are not consumed by machine but are designed for human. Is this workaround good enough to be adapted to click-help-colors or serve as inspiration?

For the record, this has initially been discussed for Cloup at janluke/cloup#95, and is considered under janluke/cloup#97.

tests missing from pypi tarball

Hi! I'm packaging python-click-help-colors for Arch Linux.

We're usually using the sdist tarballs from pypi.org, as they ensure uniqueness. However, in this case, the sdist release is missing the tests. As the sdist is supposed to contain the sources from which users can build the package, it should also contain the tests, so that they can validate, that click-help-colors integrates with their system python.

The directory can be added to MANIFEST.in and will then be available in the sdist tarball upon next release.

Incompatibility with newer click 8.0

This module chokes with newer click with already has a pre-release out:

click==8.0.0a1
  - click-completion==0.5.2 [requires: click]
  - click-help-colors==0.8 [requires: click>=7.0]
eco run-test: commands[3] | molecule --version
Traceback (most recent call last):
  File "/home/runner/work/molecule/molecule/.tox/eco/bin/molecule", line 33, in <module>
    sys.exit(load_entry_point('molecule', 'console_scripts', 'molecule')())
  File "/home/runner/work/molecule/molecule/.tox/eco/bin/molecule", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/opt/hostedtoolcache/Python/3.8.6/x64/lib/python3.8/importlib/metadata.py", line 77, in load
    module = import_module(match.group('module'))
  File "/opt/hostedtoolcache/Python/3.8.6/x64/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/runner/work/molecule/molecule/src/molecule/__main__.py", line 22, in <module>
    from molecule.shell import main
  File "/home/runner/work/molecule/molecule/src/molecule/shell.py", line 29, in <module>
    from molecule import command
  File "/home/runner/work/molecule/molecule/src/molecule/command/__init__.py", line 27, in <module>
    from molecule.command import base  # noqa
  File "/home/runner/work/molecule/molecule/src/molecule/command/base.py", line 30, in <module>
    from click_help_colors import HelpColorsCommand, HelpColorsGroup
  File "/home/runner/work/molecule/molecule/.tox/eco/lib/python3.8/site-packages/click_help_colors/__init__.py", line 6, in <module>
    from .decorators import version_option
  File "/home/runner/work/molecule/molecule/.tox/eco/lib/python3.8/site-packages/click_help_colors/decorators.py", line 6, in <module>
    from click._compat import iteritems
ImportError: cannot import name 'iteritems' from 'click._compat' (/home/runner/work/molecule/molecule/.tox/eco/lib/python3.8/site-packages/click/_compat.py)
ERROR: InvocationError for command /home/runner/work/molecule/molecule/.tox/eco/bin/molecule --version (exited with code 1)

I would recommend adding a job that test pre-releases so you find issues before dependencies make a release that breaks in the wild. With one of these jobs I discovered this bug, i have one that does "pip install --pre ...".

Is there a way to use this plugin with click.MultiCommand

Hi,

I'm trying to build a fancy cli using click and now I found this click plugin. I was able to change colors on the command1.py, but how I could do it from the first level when using the click.MultiCommand?

I'm using this approuch that best suit my needs:

.
|-- cli
|   |-- __init__.py
|   |-- cli.py
|   `-- commands
|       |-- __init__.py
|       |-- commands1.py
|       `-- commands2.py
`-- setup.py
#cli.py
import click
import os

plugin_folder = os.path.join(os.path.dirname(__file__), 'commands')

class MyCLI(click.MultiCommand):

    def list_commands(self, ctx):
        """Dynamically get the list of commands."""
        rv = []
        for filename in os.listdir(plugin_folder):
            if filename.endswith('.py') and not filename.startswith('__init__'):
                rv.append(filename[:-3])
        rv.sort()
        return rv

    def get_command(self, ctx, name):
        """Dynamically get the command."""
        ns = {}
        fn = os.path.join(plugin_folder, name + '.py')
        with open(fn) as f:
            code = compile(f.read(), fn, 'exec')
            eval(code, ns, ns)
        return ns['cli']


@click.command(cls=MyCLI)
def cli():
    """The CLI."""
    pass

if __name__ == '__main__':
    cli()
#commands1.py
import click
from click_help_colors import HelpColorsGroup, HelpColorsCommand

@click.group(cls=HelpColorsGroup,
    help_headers_color='yellow',
    help_options_color='green'
    )
def cli(): pass
@cli.command()
def c1(): click.echo("g1 c1")
@cli.command()
def c2(): click.echo("g1 c1")

if __name__ == "__main__":
    cli()

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.