Skip to content

fix: make --render work again #257

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 24, 2024
Merged

fix: make --render work again #257

merged 1 commit into from
Oct 24, 2024

Conversation

acuteenvy
Copy link
Member

This PR fixes the error when using --render.

$ tldr --render path/to/file
[...]
AttributeError: 'str' object has no attribute 'open'

Copy link
Member

@kbdharun kbdharun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the fix.


Tested the changes locally quickly with WSL (after fix, before fix):

~/tldr-python-client# python3 tldr.py --render 1.md

  tldr

  Display simple help pages for command-line tools from the tldr-pages project.
  Note: the `--language` and `--list` options are not required by the client specification, but most clients implement them.
  More information: https://github.com/tldr-pages/tldr/blob/main/CLIENT-SPECIFICATION.md#command-line-interface.

  - Print the tldr page for a specific command (hint: this is how you got here!):
    tldr command

  - Print the tldr page for a specific subcommand:
    tldr command subcommand

  - Print the tldr page for a command in the given [L]anguage (if available, otherwise fall back to English):
    tldr --language language_code command

  - Print the tldr page for a command from a specific [p]latform:
    tldr --platform android|common|freebsd|linux|osx|netbsd|openbsd|sunos|windows command

  - [u]pdate the local cache of tldr pages:
    tldr --update

  - [l]ist all pages for the current platform and common:
    tldr --list

  - [l]ist all available subcommand pages for a command:
    tldr --list | grep command | column

~/tldr-python-client# tldr --render 1.md
Traceback (most recent call last):
  File "/snap/tldr/627/bin/tldr", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/snap/tldr/627/lib/python3.12/site-packages/tldr.py", line 665, in cli
    main()
  File "/snap/tldr/627/lib/python3.12/site-packages/tldr.py", line 610, in main
    with command.open(encoding='utf-8') as open_file:
         ^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'open'

@kbdharun kbdharun merged commit cb63ef4 into main Oct 24, 2024
18 checks passed
@kbdharun kbdharun deleted the fix-render branch October 24, 2024 15:32
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.

3 participants