395 karma · joined January 20, 2012
I work full-time right now, so money isn't really an issue. I'll gladly accept commits though! ;)
I actually spent a considerable amount of time going over bash's parser [0], and also zsh's [1]. Bash uses lex/yacc with some custom code. zsh seems to have a custom written lexer/parser.
Unfortunately none of them were written to be used as a library, as evident by global state, and a lot of hooks for prompts while parsing, etc. It might be possible to somehow make it work, but it seems like a lot of work to me. You might have an easier time looking at the parser I wrote, and extending that, or rewriting it in another language (as it's fairly small compared to the ones you find in shells). There's also libbash [2], haven't looked closely though.
[0]: http://git.savannah.gnu.org/cgit/bash.git/tree/parse.y
[1]: https://github.com/zsh-users/zsh/blob/master/Src/parse.c
I only scanned sections 1 and 8 of the man page archive, so that's why files are missing.. but they can be added.
You'll be amazed how many people try this (or other 'malicious' commands), presumably thinking I'm executing the queries. ;)
Having a single line when you hover could help, but sounds confusing for new users that are unaware of this feature.
Feel free to open a bug and we can discuss the options there.
What is possible and quite easy is creating links for things that are explained in other tools, such as linking the regex argument of grep to some site that explains regular expressions, or somehow integrate it into the existing UI.
The main difficulty I had with writing a command line utility is figuring out the UI in a console. Suggestions are welcome of course.
Also, there are two possibilities for a client: the first queries an API on explainshell.com by sending it a command line. This has the advantage of the client being thin, and using the centralized man page database which is probably more accurate. But this means that you're potentially not explaining the exact command you're running locally, which may be confusing.
The second option is to run the man page parser, matcher, etc. locally against the man page on your machine.
If a JS wiz would like to hack on this I'll gladly help and accept it.
ACK on the command substitution not working, with the current lexer that I have in place fixing this isn't easy and might take a while. But it's definitely up there on my todos.
Yeah, long pipelines are somewhat of a problem. You can currently navigate the commands with the buttons at the top, maybe they're not visible enough.
But I like the idea of being able to pin a particular line by pressing it, but I fear it might be a bit subtle and easy to miss.
I agree about large commands being hard to follow. I tried solving this by adding the ability to navigate between commands. Right now clicking the command takes you to a page that displays that command options, but I can change it to the equivalent of navigating to it with the arrows at the top. There might be something better to do UI wise, though.
In the end you find yourself installing as much as possible with pip, and resort to apt for the really heavy stuff like numpy.
It's interesting because I had an idea once to do the opposite: see if explainshell could use completion files from bash/zsh/fish as another source of options besides the man page.
At some point I wanted to convert it to a DFA because I thought it will give me more control and flexibility and be more maintainable over time. The thing to look out for is not make it too permissive so it starts catching things that aren't really options.
I definitely went into this with a 'let's start with something good and useful for as many commands as possible', so I haven't focused on accuracy for those edge cases. But from what I played with it so far, results have been pretty good.
Agree again on the pipe et al. support. It's not easy, hence why I haven't added this right out of the gate. I basically have to build a parser for bash, although I can probably get away with handling only a small subset of it that is interesting in this context, such as pipes, redirections, etc. I still have to figure out how to display multiple commands, because chunking them all in one page isn't going work visually.
I'll be happy to hear more about turning this into a learning environment. It might not work for this particular tool, but maybe it can use the foundations.
If you always keep the order, lines would have to cross each other which looks less pretty and pretty confusing.
Re other flavors: do you know if there are easy ways to get a dump of all man pages, similar to Ubuntu's man page archive?
I'll open source the code sometime in the future so github would be the place for bug reports.
As for long commands, yeah they're a bit crazy right now since they get wrapped. I'm still trying to figure out the best way to display it.