3 ms·
I have a basic question: if git forwards its first argument to git-$arg, then how would you produce a list of all possible git commands? Is there something lik
by sillysaurusx 5y ago
I have a basic question: if git forwards its first argument to git-$arg, then how would you produce a list of all possible git commands?
Is there something like ls, but for possible programs on your PATH? Or is there a way to just get a dump of all executables on the current PATH?
Even still, it seems like you’d have to decide which of those programs to show first in the documentation. And to get a short description of each of them, you’d have to invoke them.
I guess the solution is “use manpages,” but it’s kind of unsatisfying — I’d like to build something like git, but using CLI --help.
EDIT: Seems ... strange.
- https://github.com/git/git/blob/master/help.c#L260-L294 https://github.com/git/git/blob/master/help.c#L260-L294
- https://github.com/git/git/blob/master/command-list.txt https://github.com/git/git/blob/master/command-list.txt
- https://github.com/git/git/blob/master/generate-cmdlist.sh https://github.com/git/git/blob/master/generate-cmdlist.sh
I'm not sure `git help` supports the concept of adding third-party `git` commands as first-class citizens, but I'm still reading.
- mdaniel 5y ago"git help -a" specifically performs that same discovery process and lists what it finds (including aliases!), so one need not reinvent that wheel
- sillysaurusx 5y agoIt seems like `git help -a` doesn't allow third-party commands to have docstrings at all. It seems to call getenv("PATH"), then calls readdir on each folder, filters out any non-executables that aren't prefixed with "git-", and then lists those under the "External commands" category with no further help. I was hoping there was a way to attach a short help descriptor to each of the third-party commands. But the help descriptors seem to be hardcoded for the builtin commands, with no support for third party commands. Darn.
- Aeolun 5y agoKind of scary to execute all git- prefixed commands when you run ‘git help’. Maybe have a location where git stores descriptions for external commands?