Skip to content

fix command line option "--width"#13

Merged
FredHappyface merged 2 commits into
FHPythonUtils:masterfrom
haochenx:fix-opt-width
Sep 22, 2023
Merged

fix command line option "--width"#13
FredHappyface merged 2 commits into
FHPythonUtils:masterfrom
haochenx:fix-opt-width

Conversation

@haochenx
Copy link
Copy Markdown
Contributor

when specifying --width, i'm getting the following error:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/opt/homebrew/lib/python3.11/site-packages/ansitoimg/__main__.py", line 6, in <module>
    cli()
  File "/opt/homebrew/lib/python3.11/site-packages/ansitoimg/__init__.py", line 79, in cli
    ansiToSVG(ansi, args.output, args.theme, width=width, title=args.title)
  File "/opt/homebrew/lib/python3.11/site-packages/ansitoimg/render.py", line 79, in ansiToSVG
    console = _doRichRender(ansiText, _resolveWidth(wide, width))
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/ansitoimg/render.py", line 23, in _doRichRender
    console.print(richText)
  File "/opt/homebrew/lib/python3.11/site-packages/rich/console.py", line 1694, in print
    extend(render(renderable, render_options))
  File "/opt/homebrew/lib/python3.11/site-packages/rich/console.py", line 1299, in render
    if _options.max_width < 1:
       ^^^^^^^^^^^^^^^^^^^^^^
TypeError: '<' not supported between instances of 'str' and 'int'

This PR attempts to fix it.

@FredHappyface
Copy link
Copy Markdown
Member

Hi thanks for this, would it be possible to do the int cast when we parse the args?

@haochenx
Copy link
Copy Markdown
Contributor Author

would it be possible to do the int cast when we parse the args?

Make sense. I just revised the PR.

@FredHappyface
Copy link
Copy Markdown
Member

Awesome stuff, thank you so much for that 😄

@FredHappyface FredHappyface merged commit 6e36965 into FHPythonUtils:master Sep 22, 2023
@haochenx
Copy link
Copy Markdown
Contributor Author

Thanks!

@haochenx haochenx deleted the fix-opt-width branch September 23, 2023 01:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants