click-contrib / click-help-colors Goto Github PK
View Code? Open in Web Editor NEWColorization of help messages in Click :art:
License: MIT License
Colorization of help messages in Click :art:
License: MIT License
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.
Hey great work.
please add additional colors for error message, eg.
thx
sam
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:
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.
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.
Using the NO_COLOR environment variable is a de facto standard for disabling/enabling colored output.
See https://no-color.org/ for details.
Programs should respect it and libraries should aid us to do so.
It seems that the library is missing type information.
Related:
Hello,
I encounter the issue that when I'm using click-plugin
to plug subcommands, together with HelpColorsGroup
. I see the colors on the group command, but not on the subcommands.
Do you have any suggestions?
Thanks
Please can you issue a new release with the patch for click 8 support?
thanks!
LICENSE.txt
is not uploaded on pypi as MANIFEST.in
file seems to be missing.
See conda-forge/staged-recipes#1696
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 ...".
As visible in your own screenshot, help_headers_color is applied to "Usage:" (including the colon) but not to the colons in "Options" and "Commands".
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()
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.