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

Better/More detailed --list #334

Closed
marcmenem opened this issue Jul 14, 2023 · 5 comments
Closed

Better/More detailed --list #334

marcmenem opened this issue Jul 14, 2023 · 5 comments

Comments

@marcmenem
Copy link

marcmenem commented Jul 14, 2023

Awesome tool!

I think it would be useful to have two columns in --list with the command and the 1 line description of the command next to it. This would help discovering new commands or remember a command name by grepping a keyword.

@niklasmohrin
Copy link
Collaborator

Thanks! My first impression is that this does not really sound like something that users would do often. Additionally, I think that it should not be too difficult to implement the desired behavior as a short shell script instead. What do you think?

@marcmenem
Copy link
Author

tbh, I wouldn't know how to write this shell script, it would probably be quicker to google the command I am looking for...

@Yakiyo
Copy link

Yakiyo commented Aug 22, 2023

columns may make the output easier on the eyes but the current impl is actually better for other tools like grep-ing command names, and/or filtering stuff. Could maybe ig support an additional flag that can switch between pretty-printing (columns) or regular printing (the current one)

@niklasmohrin
Copy link
Collaborator

Does this Python script solve your problem?

#!/usr/bin/env python3

import subprocess

commands = subprocess.run(
    ["tldr", "-l"],
    capture_output=True,
    encoding="utf-8",
).stdout.splitlines()

for command in commands:
    output = subprocess.run(
        ["tldr", command],
        capture_output=True,
        encoding="utf-8",
    ).stdout
    description = output.lstrip().split("\n\n")[0]
    description = " ".join(description.split())
    print(f"{command} => {description}")

Looking at the output, I would argue that it is hard to display all of this information in a concise or useful way

@niklasmohrin
Copy link
Collaborator

Closing because the script seems sufficient (and is mentioned in the manual now) :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants