Skip to content

Commit b9e8e8d

Browse files
committed
readme: consolidate docker sections
1 parent 4ee57d3 commit b9e8e8d

File tree

2 files changed

+16
-48
lines changed

2 files changed

+16
-48
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
tests:
2-
nosetests --with-doctest tests/ explainshell/
2+
nosetests --exe --with-doctest tests/ explainshell/
33

44
serve:
55
python runserver.py

README.md

+15-47
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# [explainshell.com](http://www.explainshell.com) - match command-line arguments to their help text
22

33
explainshell is a tool (with a web interface) capable of parsing man pages, extracting options and
4-
explain a given command-line by matching each argument to the relevant help text in the man page.
4+
explaining a given command-line by matching each argument to the relevant help text in the man page.
55

66
## How?
77

@@ -19,9 +19,9 @@ When querying explainshell, it:
1919

2020
1. parses the query into an AST
2121
2. visits interesting nodes in the AST, such as:
22-
- command nodes - these nodes represent a simple command
23-
- shell related nodes - these nodes represent something the shell
24-
interprets such as '|', '&&'
22+
- command nodes - these nodes represent a simple command
23+
- shell related nodes - these nodes represent something the shell
24+
interprets such as '|', '&&'
2525
3. for every command node we check if we know how to explain the current program,
2626
and then go through the rest of the tokens, trying to match each one to the
2727
list of known options
@@ -40,23 +40,30 @@ Setup a working environment that lets you run the web interface locally using do
4040

4141
```ShellSession
4242
# download db dump
43-
$ curl -L -o /tmp/dump.gz https://github.com/idank/explainshell/releases/download/db-dump/dump.gz
43+
curl -L -o /tmp/dump.gz https://github.com/idank/explainshell/releases/download/db-dump/dump.gz
4444

4545
# start containers, load man pages from dump
4646
docker-compose build
4747
docker-compose up
4848

4949
docker-compose exec -T db mongorestore --archive --gzip < /tmp/dump.gz
5050

51-
# open http://localhost:5000
51+
# run tests
52+
docker-compose exec -T web make tests
53+
..SSSSSSSSS.....................................................................
54+
----------------------------------------------------------------------
55+
Ran 80 tests in 0.041s
56+
57+
OK (SKIP=9)
58+
# open http://localhost:5000 to view the ui
5259
```
5360

5461
### Processing a man page
5562

5663
Use the manager to parse and save a gzipped man page in raw format:
5764

5865
```ShellSession
59-
$ PYTHONPATH=. python explainshell/manager.py --log info manpages/1/echo.1.gz
66+
$ docker-compose exec -T web bash -c "PYTHONPATH=. python explainshell/manager.py --log info /usr/share/man/man1/echo.1.gz"
6067
INFO:explainshell.store:creating store, db = 'explainshell_tests', host = 'mongodb://localhost'
6168
INFO:explainshell.algo.classifier:train on 994 instances
6269
INFO:explainshell.manager:handling manpage echo (from /tmp/es/manpages/1/echo.1.gz)
@@ -71,43 +78,4 @@ INFO:explainshell.store:inserting mapping (alias) echo -> echo (52207a1fa9b52e42
7178
successfully added echo
7279
```
7380

74-
### Start up a local web server
75-
76-
```ShellSession
77-
$ make serve
78-
python runserver.py
79-
* Running on http://127.0.0.1:5000/
80-
* Restarting with reloader
81-
```
82-
83-
### Start up a local web server with docker
84-
85-
```ShellSession
86-
# Build docker web and db containers
87-
$ docker-compose build
88-
$ docker-compose up
89-
90-
# Copy dump over to container for than to import it.
91-
$ docker cp dump/ explainshell_db_1:/tmp/dump
92-
93-
# Import classifiers
94-
$ docker exec explainshell_db_1 mongorestore /tmp/dump
95-
96-
# Import a man page
97-
$ docker exec explainshell_web_1 bash -c "PYTHONPATH=. python explainshell/manager.py --log info /usr/share/man/man1/grep.1.gz"
98-
...
99-
successfully added grep.1.gz
100-
101-
# Open browser at port 5000
102-
$ open http://localhost:5000
103-
104-
# Restore test db to run tests
105-
$ docker exec explainshell_db_1 mongorestore -d explainshell_tests /tmp/dump/explainshell
106-
107-
$ docker exec explainshell_web_1 make tests
108-
..............................................................................
109-
----------------------------------------------------------------------
110-
Ran 79 tests in 3.847s
111-
112-
OK
113-
```
81+
Note that if you've setup using the docker instructions above, echo will already be in the database.

0 commit comments

Comments
 (0)