deps.clj docs

This commit is contained in:
Michiel Borkent 2020-04-22 12:06:11 +02:00
parent 83ebeaf96f
commit 04c34d24e5
3 changed files with 70 additions and 67 deletions

View file

@ -516,73 +516,7 @@ Also see the
[babashka.classpath](https://github.com/borkdude/babashka/#babashkaclasspath) [babashka.classpath](https://github.com/borkdude/babashka/#babashkaclasspath)
namespace which allows dynamically adding to the classpath. namespace which allows dynamically adding to the classpath.
### Deps.clj See [deps.clj](doc/deps.clj.md) for a babashka script that replaces the `clojure` bash script.
The [`deps.clj`](https://github.com/borkdude/deps.clj/) script can be used to work with `deps.edn`-based projects:
``` shell
$ deps.clj -A:my-script -Scommand "bb -cp {{classpath}} {{main-opts}}"
Hello from gist script!
```
Create these aliases for brevity:
``` shell
$ alias bbk='deps.clj -Scommand "bb -cp {{classpath}} {{main-opts}}"'
$ alias babashka='rlwrap deps.clj -Scommand "bb -cp {{classpath}} {{main-opts}}"'
$ bbk -A:my-script
Hello from gist script!
$ babashka
Babashka v0.0.58 REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.
user=> (require '[my-gist-script :as mgs])
nil
user=> (mgs/-main)
Hello from gist script!
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

67
doc/deps.clj.md Normal file
View file

@ -0,0 +1,67 @@
### Deps.clj
The [`deps.clj`](https://github.com/borkdude/deps.clj/) script can be used to work with `deps.edn`-based projects:
``` shell
$ deps.clj -A:my-script -Scommand "bb -cp {{classpath}} {{main-opts}}"
Hello from gist script!
```
Create these aliases for brevity:
``` shell
$ alias bbk='deps.clj -Scommand "bb -cp {{classpath}} {{main-opts}}"'
$ alias babashka='rlwrap deps.clj -Scommand "bb -cp {{classpath}} {{main-opts}}"'
$ bbk -A:my-script
Hello from gist script!
$ babashka
Babashka v0.0.58 REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.
user=> (require '[my-gist-script :as mgs])
nil
user=> (mgs/-main)
Hello from gist script!
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`.

View file

@ -7,6 +7,8 @@ The following projects are known to work with babashka.
A port of the [clojure](https://github.com/clojure/brew-install/) bash script to A port of the [clojure](https://github.com/clojure/brew-install/) bash script to
Clojure / babashka. Clojure / babashka.
Also see [deps.clj documentation](../doc/deps.clj.md).
#### [spartan.spec](https://github.com/borkdude/spartan.spec/) #### [spartan.spec](https://github.com/borkdude/spartan.spec/)
An babashka-compatible implementation of `clojure.spec.alpha`. An babashka-compatible implementation of `clojure.spec.alpha`.