match command-line arguments to their help text
explainshell is a tool (with a web interface) capable of parsing man pages, extracting options and explain a given command-line by matching each argument to the relevant help text in the man page.
explainshell is built from the following components:
When querying explainshell, it:
Right now explainshell.com contains the entire archive of Ubuntu. It's not possible to directly add a missing man page to the live site (it might be in the future). Instead, submit a link here and I'll add it.
To setup a working environment that lets you run the web interface locally, you'll need to:
$ pip install -r requirements.txtload classifier data, needs a mongodb
$ mongorestore dump/explainshell && mongorestore -d explainshell_tests dump/explainshell $ make tests ..............................................................................
Ran 79 tests in 3.847s
OK
Use the manager to parse and save a gzipped man page in raw format:
$ PYTHONPATH=. python explainshell/manager.py --log info manpages/1/echo.1.gz INFO:explainshell.store:creating store, db = 'explainshell_tests', host = 'mongodb://localhost' INFO:explainshell.algo.classifier:train on 994 instances INFO:explainshell.manager:handling manpage echo (from /tmp/es/manpages/1/echo.1.gz) INFO:explainshell.store:looking up manpage in mapping with src 'echo' INFO:explainshell.manpage:executing '/tmp/es/tools/w3mman2html.cgi local=%2Ftmp%2Fes%2Fmanpages%2F1%2Fecho.1.gz' INFO:explainshell.algo.classifier:classified (0.991381) as an option paragraph INFO:explainshell.algo.classifier:classified (0.996904) as an option paragraph INFO:explainshell.algo.classifier:classified (0.998640) as an option paragraph INFO:explainshell.algo.classifier:classified (0.999215) as an option paragraph INFO:explainshell.algo.classifier:classified (0.999993) as an option paragraph INFO:explainshell.store:inserting mapping (alias) echo -> echo (52207a1fa9b52e42fb59df36) with score 10 successfully added echo
$ make serve python runserver.py * Running on http://127.0.0.1:5000/ * Restarting with reloader
# Build docker web and db containers $ docker-compose build $ docker-compose upCopy dump over to container for than to import it.
$ docker cp dump/ explainshell_db_1:/tmp/dump
Import classifiers
$ docker exec explainshell_db_1 mongorestore /tmp/dump
Import a man page
$ docker exec explainshell_web_1 bash -c "PYTHONPATH=. python explainshell/manager.py --log info /usr/share/man/man1/grep.1.gz" ... successfully added grep.1.gz
Open browser at port 5000
$ open http://localhost:5000
Restore test db to run tests
$ docker exec explainshell_db_1 mongorestore -d explainshell_tests /tmp/dump/explainshell
$ docker exec explainshell_web_1 make tests ..............................................................................
Ran 79 tests in 3.847s
OK