-
-
Notifications
You must be signed in to change notification settings - Fork 180
Scripts
It's possible to create self-contained, executable Clojure scripts that can bring in Maven dependencies, using a shebang. Here is an example that runs a game like Lunar Lander:
Put this into a file called lunarlander
:
#!/usr/bin/env boot
(set-env! :dependencies '[[alandipert/hyperturbo "1.0.0"]])
(require '[alandipert.hyperturbo.lunar-lander :refer [run]])
(defn -main [& args]
(run))
NOTE: Github wiki's syntax formatting is messed up and eats single quotes sometimes. The vector passed to set-env! above should be quoted.
Make the file executable:
chmod +x lunarlander
Run the script:
./lunarlander
If you define a -main
function, it will be called and passed any command-line arguments.
(defn -main [& args]
...)
You can use Boot's built-in arg specification macro to get parsing of named args and automatic --help generation as well:
(require '[boot.cli :refer [defclifn]])
(defclifn -main
[a awesome bool "Whether you want this app to be awesome or not. (Default true)"]
...)
In addition to the raw task *opts*
, defclifn
exports trailing-arguments bound to *args*
:
(require '[boot.cli :refer [defclifn]])
(defclifn -main
[a awesome bool "Whether you want this app to be awesome or not. (Default true)"]
(println "Named parameters " *opts*)
(println "List of arguments " *args*))
(boot (some-task))
You can find other developers and users in the #hoplon
channel on freenode IRC or the boot slack channel.
If you have questions or need help, please visit the Discourse site.
- Environments
- Boot environment
- Java environment
- Tasks
- Built-ins
- Third-party
- Tasks Options
- Filesets
- Target Directory
- Pods
- Boot Exceptions
- Configuring Boot
- Updating Boot
- Setting Clojure version
- JVM Options
- S3 Repositories
- Scripts
- Task Writer's Guide
- Require inside Tasks
- Boot for Leiningen Users
- Boot in Leiningen Projects
- Repl reloading
- Repository Credentials and Deploying
- Snippets
- Troubleshooting
- FAQ
- API docs
- Core
- Pod
- Util