dbrgn / tealdeer

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

Add a `--edit` option #286

Closed BuonOmo closed 1 year ago

BuonOmo commented 1 year ago

This option will help contributing, as the edit this page on github button does on https://tldr.ostera.io/man.

This is a minimum viable product. If you feel this is interesting, I could go further and open an editor if the page is a local page or if it contains a patch. To do so, I was thinking of refactoring a tiny bit PageLookupResult to contain those information.

BuonOmo commented 1 year ago

@niklasmohrin definitely agree with all of your points. I don't think I'll have the time to dive into specification discussion. I'll just ping them there about this idea to give them more insights on how it could be done.

I could also, as an alternative proposition, just add the link in the presentation of the command directly:

$ tldr command
  Command forces the shell to execute the program and ignore any functions, builtins and aliases with the same name.
  More information: <https://manned.org/command>.

  Execute the `ls` program literally, even if an `ls` alias exists:

      command ls

  Display the path to the executable or the alias definition of a specific command:

      command -v command_name

Edit this page on GitHub: https://github.com/tldr-pages/tldr/edit/main/pages/common/command.md
niklasmohrin commented 1 year ago

That's okay :) About appending it to the output: My first impression is that the tldr pages are explicitly designed to be compact and I would hate it if users would have to scroll up one line just because we have this "contribution advertisement". As a user, this could possibly annoy me into switching to another client. I am against changing the default behavior in this way.

Another thought for the spec discussion: This output could be an idea for --edit. We could make it mean that the flag doesn't work like a subcommand, but rather an additional option to the default behavior (i.e. tldr command is unchanged and tldr --edit command outputs what you wrote above). This would also allow for having this flag permanently enabled by config or so.

However, I think I like the initial proposal better, because we can then put more information about editing, not just one line. :D

BuonOmo commented 1 year ago

Closing for now, we'll see how specs evolve. In the mean time I'll be using my branch, and anyone in favor of that could. I'll update it if requested