sdispater / clikit

CliKit is a group of utilities to build beautiful and testable command line interfaces.
MIT License
72 stars 17 forks source link

Misnamed pastel option #11

Closed ghost closed 4 years ago

ghost commented 4 years ago

I came to this issue while running poetry. My setup involves:

In clikit-0.4.1, option "underscore" is adapted from "underline". See the following snippet: https://github.com/sdispater/clikit/blob/0.4.1/src/clikit/adapter/style_converter.py#L19.

Thus, when running poetry, the following error occurs:

$ python -V
Python 3.8.1
$ poetry   
Traceback (most recent call last):
  File "/usr/bin/poetry", line 11, in <module>
    load_entry_point('poetry==1.0.0', 'console_scripts', 'poetry')()
  File "/usr/lib/python3.8/site-packages/poetry/console/__init__.py", line 5, in main
    return Application().run()
  File "/usr/lib/python3.8/site-packages/poetry/console/application.py", line 32, in __init__
    super(Application, self).__init__(
  File "/usr/lib/python3.8/site-packages/cleo/application.py", line 29, in __init__
    super(Application, self).__init__(config)
  File "/usr/lib/python3.8/site-packages/clikit/console_application.py", line 32, in __init__
    self._preliminary_io = ConsoleIO()
  File "/usr/lib/python3.8/site-packages/clikit/io/console_io.py", line 31, in __init__
    formatter = AnsiFormatter()
  File "/usr/lib/python3.8/site-packages/clikit/formatter/ansi_formatter.py", line 26, in __init__
    pastel_style = StyleConverter.convert(style)
  File "/usr/lib/python3.8/site-packages/clikit/adapter/style_converter.py", line 30, in convert
    return PastelStyle(style.foreground_color, style.background_color, options)
  File "/usr/lib/python3.8/site-packages/pastel/style.py", line 74, in __init__
    self.set_options(options)
  File "/usr/lib/python3.8/site-packages/pastel/style.py", line 133, in set_options
    self.set_option(option)
  File "/usr/lib/python3.8/site-packages/pastel/style.py", line 110, in set_option
    raise ValueError(
ValueError: Invalid option specified: "underscore". Expected one of (bold, dark, italic, underline, blink, reverse, conceal)

Applying the patch given below resolves this issue.

ghost commented 4 years ago

Bugfix proposal: https://gist.github.com/Amossys-team/6fa807950050eb111d07c8c79e59bb15

ghost commented 4 years ago

For further detail on the pastel side, this is what pastel expects as valid options: https://github.com/sdispater/pastel/blob/0.2.0/pastel/style.py#L48

sdispater commented 4 years ago

clikit 0.4.1 is not compatible with pastel 0.2.0 as you can see here : https://github.com/sdispater/clikit/blob/master/pyproject.toml#L20

I don't know how you ended up with this set of package versions but they are not expected to work together.