Skip to content
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

Implement option length selection with options and environment variables #259

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

Managor
Copy link

@Managor Managor commented Dec 13, 2024

Initial ideas on how to implement the shortform/longform print modes.

@Managor Managor marked this pull request as draft December 13, 2024 16:27
@Managor
Copy link
Author

Managor commented Dec 13, 2024

Related issue tldr-pages/tldr#13556

@sbrl
Copy link
Member

sbrl commented Dec 13, 2024

Seems interesting. Does this always hold up with all instances of {{a|b}} where {{-a|--b}}?

What would you envision the CLI to look like for tldr? Could you disable the short/longform parsing support and display everything at all? What would the default be?

tldr.py Outdated
@@ -478,6 +478,13 @@ def emphasise_example(x: str) -> str:
line = line.replace(r'\{\{', '__ESCAPED_OPEN__')
line = line.replace(r'\}\}', '__ESCAPED_CLOSE__')

# Extract long or short options from placeholders
if not (shortform and longform):
Copy link
Author

Choose a reason for hiding this comment

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

Default would obiously be True for both so that this condition causes a skip. I'm not certain what you're asking in the rest of the comment.

@acuteenvy
Copy link
Member

What about tools that don't follow this convention for short and long options (e.g. tldr-pages/tldr#13556 (comment))?
I don't think there's a way to fully support option selection without introducing special syntax as discussed in tldr-pages/tldr#5092.

@Managor
Copy link
Author

Managor commented Dec 13, 2024

If a tool doesn't follow this convention then it won't be affected by this. Simple as that.

@acuteenvy
Copy link
Member

This regular expression won't work if there are multiple short options in a single placeholder.
Example:
https://github.com/tldr-pages/tldr/blob/3823ba7fc64e2c368e87950f1aaf407d88f6957f/pages/common/rsync.md#L17

`rsync {{-zvhP|--compress --verbose --human-readable --partial --progress}} {{path/to/source}} {{path/to/destination}}`

@acuteenvy acuteenvy changed the title Initial work on option lenght selection Initial work on option length selection Dec 14, 2024
@Managor
Copy link
Author

Managor commented Dec 14, 2024

That is by design. Like I said in the original issue, the initial implementation should be as strict as possible.

EDIT: However. That example is pretty nice for condensing the shortform options. Maybe I should allow it to be picked up.

@Managor
Copy link
Author

Managor commented Dec 15, 2024

Alright, I'm looking for feedback again. Is this the proper way to implement options? Also how can I implement TLDR_SHORTFORM and TLDR_LONGFORM env variables?

@Managor
Copy link
Author

Managor commented Dec 15, 2024

Nvm figured it out. Now I'm just looking for feedback.

@Managor Managor marked this pull request as ready for review December 20, 2024 02:58
@Managor Managor changed the title Initial work on option length selection Implement option length selection with options and environment variables Dec 20, 2024
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