Added two examples on how to construct a classpath to README.md (#334)
This commit is contained in:
parent
74d3cf4140
commit
fab7fedfea
1 changed files with 62 additions and 0 deletions
62
README.md
62
README.md
|
|
@ -455,6 +455,28 @@ $ bb --classpath src --main my.namespace
|
||||||
Hello from my namespace!
|
Hello from my namespace!
|
||||||
```
|
```
|
||||||
|
|
||||||
|
So if you have a larger script with a classic Clojure project layout like
|
||||||
|
|
||||||
|
```shellsession
|
||||||
|
$ tree -L 3
|
||||||
|
├── deps.edn
|
||||||
|
├── README
|
||||||
|
├── src
|
||||||
|
│ └── project_namespace
|
||||||
|
│ ├── main.clj
|
||||||
|
│ └── utilities.clj
|
||||||
|
└── test
|
||||||
|
└── project_namespace
|
||||||
|
├── test_main.clj
|
||||||
|
└── test_utilities.clj
|
||||||
|
```
|
||||||
|
Then you can tell Babashka to include both the `src` and `test`
|
||||||
|
folders in the classpath and start a socket REPL by running:
|
||||||
|
|
||||||
|
```shellsession
|
||||||
|
$ bb --classpath src:test --socket-repl 1666
|
||||||
|
```
|
||||||
|
|
||||||
Note that you can use the `clojure` tool to produce classpaths and download dependencies:
|
Note that you can use the `clojure` tool to produce classpaths and download dependencies:
|
||||||
|
|
||||||
``` shellsession
|
``` shellsession
|
||||||
|
|
@ -512,6 +534,46 @@ Hello from gist script!
|
||||||
nil
|
nil
|
||||||
```
|
```
|
||||||
|
|
||||||
|
You can also use for example `deps.clj` to produce the classpath for a
|
||||||
|
`babashka` REPL:
|
||||||
|
|
||||||
|
```shellsession
|
||||||
|
$ cat script/start-repl.sh
|
||||||
|
#!/bin/sh -e
|
||||||
|
git_root=$(git rev-parse --show-toplevel)
|
||||||
|
export BABASHKA_CLASSPATH=$("$git_root"/script/deps.clj -Spath)
|
||||||
|
bb --socket-repl 1666
|
||||||
|
$ ./script/start-repl.sh
|
||||||
|
Babashka socket REPL started at localhost:1666
|
||||||
|
```
|
||||||
|
|
||||||
|
Now, given that your `deps.edn` and source tree looks something like
|
||||||
|
|
||||||
|
```shellsession
|
||||||
|
$ cat deps.edn
|
||||||
|
{:paths ["src" "test"]
|
||||||
|
:deps {}}
|
||||||
|
$ tree -L 3
|
||||||
|
├── deps.edn
|
||||||
|
├── README
|
||||||
|
├── script
|
||||||
|
│ ├── deps.clj
|
||||||
|
│ └── start-repl.sh
|
||||||
|
├── src
|
||||||
|
│ └── project_namespace
|
||||||
|
│ ├── main.clj
|
||||||
|
│ └── utilities.clj
|
||||||
|
└── test
|
||||||
|
└── project_namespace
|
||||||
|
├── test_main.clj
|
||||||
|
└── test_utilities.clj
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
you should now be able to `(require '[multi-machine-rsync.utilities :as util])`
|
||||||
|
in your REPL and the source code in `/src/multi_machine_rsync/utilities.clj`
|
||||||
|
will be evaluated and made available through the symbol `util`.
|
||||||
|
|
||||||
## Uberscript
|
## Uberscript
|
||||||
|
|
||||||
The `--uberscript` option collects the expressions in
|
The `--uberscript` option collects the expressions in
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue