dbrgn / tealdeer

A very fast implementation of tldr in Rust.
https://dbrgn.github.io/tealdeer/
Apache License 2.0
4.06k stars 123 forks source link

Better/More detailed --list #334

Closed marcmenem closed 10 months ago

marcmenem commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 12 months ago

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 commented 10 months ago

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