on master help sign in
Rewrite documentation
commit7ff2f508cdfe33baaad29138bc4f54665d876a06 authorRadon Rosborough <radon.neon@gmail.com> dateMon 3 Jun 2019, 15:14 (7 years ago) parentc5e45af
2 files changed+59−37
README.md+47−30 utils/utils.go+12−7
README.md+47−30
@@ -1,33 +1,36 @@
11# ![Prybar](logo.svg)
22
3−Prybar is a universal interpreter front-end. Same interface, same REPL, different languages.
3+Prybar is a universal interpreter front-end. Same interface, same
4+REPL, different languages.
45
56## Why
67
7−At [Repl.it](https://repl.it) we're in the business of running REPLs. As it happens to be
8−every language implements them differently. We wanted them to all behave the same: run code and drop into a REPL!
8+At [Repl.it](https://repl.it) we're in the business of running REPLs.
9+As it happens to be, every language implements them differently. We
10+wanted them to all behave the same: run code and drop into a REPL!
911
1012## How it works
1113
12−Prybar, written in Golang, maintains a common command-line interface that calls into
13−a select language backend. The language backends are implemented using cgo and the language's C-bindings.
14+Prybar, written in Golang, maintains a common command-line interface
15+that calls into a select language backend. When possible, the language
16+backends are implemented using cgo and the language's C-bindings.
17+Otherwise, they make use of a small script written in the host
18+language which starts a Prybar-compatible REPL.
1419
1520## Usage
1621
17−```
18−Usage of ./prybar-language:
19− -I like -i, but never use language REPL
20− -c string
21− code to run
22− -e string
23− expression to print
24− -i interactive
25− -ps1 string
26− PS1 (default "--> ")
27− -ps2 string
28− PS2 (default "... ")
29− -q quiet
30−```
22+ Usage: ./prybar-LANG [FLAGS] [FILENAME]...
23+ -I interactive (use readline repl)
24+ -c string
25+ execute without printing result
26+ -e string
27+ evaluate and print result
28+ -i interactive (use language repl)
29+ -ps1 string
30+ repl prompt (default "--> ")
31+ -ps2 string
32+ repl continuation prompt (default "... ")
33+ -q don't print language version
3134
3235## Language Support
3336
@@ -44,23 +47,36 @@ Usage of ./prybar-language:
4447| Julia | ✔ | ✗ | ✔ | ✔ | ✗ | ✔ |
4548| OCaml | ✔ | ✔ | ✔ | ✔ | ✗ | ✔ |
4649
47−## Building
50+## Build and run
4851
49−Prybar uses a Unix make file to build each Prybar binary with `pkg-config` to find language dependencies on your system.
52+Prybar uses Docker to make it easy to get started with development.
53+First, you must [install Docker](https://docs.docker.com/install/).
54+Then, run:
5055
51−### Linux
56+ $ docker build . -t prybar
5257
53−See [Dockerfile](Dockerfile) for hints what packages to install on linux.
58+to create a Docker image containing the Prybar code and all of its
59+dependencies. Building the image also includes compiling the Prybar
60+binaries (there is one for each supported language).
5461
55−### OSX
62+To run the code in a Docker container:
5663
57−```
58−brew install go r ruby python python@2 lua spidermonkey opam
59−```
64+ $ docker run --rm -it prybar
65+ # ./prybar-python3 -h
6066
61−## Docker
67+The directory contains one `./prybar-LANG` binary for each supported
68+language `LANG` ([see the `languages` subdirectory of this
69+repository](languages)).
6270
63−The script `./extract.sh` can be used to compile and produce a tarball containing all the Prybar binaries. Each binary will be named `prybar-<language>`. You can build all languages by running `make` in the repo's root or run `make prybar-<language>` to build a specific language.
71+When you make changes to the code, you must re-run `docker build` to
72+create a new Docker image before you can run it with `docker run`.
73+
74+### Distribution
75+
76+The script `./extract.sh` can be used to compile and produce a tarball
77+containing all the Prybar binaries. You can run it on its own; it will
78+automatically compile a new Docker image if necessary and extract the
79+binaries from a running container.
6480
6581## License
6682
@@ -78,7 +94,8 @@ GNU General Public License for more details.
7894
7995You should have received a copy of the GNU General Public License
8096along with this program; if not, write to the Free Software
81−Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
97+Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA
98+02110-1335, USA.
8299
83100See the COPYING file for more information regarding the GNU General
84101Public License.
utils/utils.go+12−7
@@ -19,15 +19,20 @@ type Config struct {
1919func ParseFlags() *Config {
2020 config := &Config{}
2121
22− flag.StringVar(&config.Code, "c", "", "code to run")
23− flag.StringVar(&config.Exp, "e", "", "expression to print")
22+ flag.StringVar(&config.Code, "c", "", "execute without printing result")
23+ flag.StringVar(&config.Exp, "e", "", "evaluate and print result")
2424
25− flag.StringVar(&config.Ps1, "ps1", "--> ", "PS1")
26− flag.StringVar(&config.Ps2, "ps2", "... ", "PS2")
25+ flag.StringVar(&config.Ps1, "ps1", "--> ", "repl prompt")
26+ flag.StringVar(&config.Ps2, "ps2", "... ", "repl continuation prompt")
2727
28− flag.BoolVar(&config.Interactive, "i", false, "interactive")
29− flag.BoolVar(&config.OurInteractive, "I", false, "like -i, but never use language REPL")
30− flag.BoolVar(&config.Quiet, "q", false, "quiet")
28+ flag.BoolVar(&config.Interactive, "i", false, "interactive (use language repl)")
29+ flag.BoolVar(&config.OurInteractive, "I", false, "interactive (use readline repl)")
30+ flag.BoolVar(&config.Quiet, "q", false, "don't print language version")
31+
32+ flag.Usage = func() {
33+ fmt.Fprintf(os.Stderr, "Usage: %s [FLAGS] [FILENAME]...\n", os.Args[0])
34+ flag.PrintDefaults()
35+ }
3136
3237 flag.Parse()
3338