Skip to content

Commit

Permalink
Add -i,--init and -f,--file boot opts; deprecate speak
Browse files Browse the repository at this point in the history
- fixes #465
  • Loading branch information
micha committed Jul 31, 2016
1 parent 96b465a commit be5c751
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
8 changes: 7 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@

##### Boot Options

- Added `-i, --init` — evaluates a form after evaluating the profile.boot
forms but before the main script or build.boot forms [#465][465].
- Added `-f, --file` — evaluates the contents of a file just like with
the shebang script, but easier to use on platforms like Windows that don't
have great shebang support [#465][465].
- Removed `-t, --target-path` and `-T, --no-target` [#475][475].

##### Task Options
Expand All @@ -43,9 +48,10 @@ N/A

#### Deprecated

N/A
- The `speak` task, replaced by `notify`.

[230]: https://github.com/boot-clj/boot/issues/230
[465]: https://github.com/boot-clj/boot/issues/465
[469]: https://github.com/boot-clj/boot/issues/469
[471]: https://github.com/boot-clj/boot/issues/471
[475]: https://github.com/boot-clj/boot/issues/475
Expand Down
11 changes: 8 additions & 3 deletions boot/core/src/boot/main.clj
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
["-e" "--set-env KEY=VAL" "Add KEY => VAL to project env map."
:assoc-fn #(let [[k v] (string/split %3 #"=" 2)]
(update-in %1 [%2] (fnil assoc {}) (keyword k) v))]
["-i" "--init EXPR" "Evaluate EXPR in the boot.user context."
:assoc-fn #(update-in %1 [%2] (fnil conj []) (read-string %3))]
["-f" "--file PATH" "Evaluate PATH (implies -BP). Args and options passed to -main."]
["-h" "--help" "Print basic usage and help info."]
["-o" "--offline" "Don't attempt to access remote repositories." :id :offline?]
["-P" "--no-profile" "Skip loading of profile.boot script."]
Expand Down Expand Up @@ -74,12 +77,13 @@
forms
[`(comment ~(format "end %s" tag))]))

(defn emit [boot? argv userscript localscript bootscript import-ns]
(defn emit [boot? argv userscript localscript bootscript import-ns inits]
(let [boot-use '[boot.core boot.util boot.task.built-in]]
`(~(list 'ns 'boot.user
(list* :use (concat boot-use import-ns)))
~@(when userscript (with-comments "global profile" userscript))
~@(when localscript (with-comments "local profile" localscript))
~@(when (seq inits) (with-comments "--init exprs" inits))
~@(with-comments "boot script" bootscript)
(let [boot?# ~boot?]
(if-not boot?#
Expand Down Expand Up @@ -129,7 +133,8 @@
:else [nil args*])
boot? (contains? #{nil bootscript} arg0)
[errs opts args] (if-not boot? [nil {} args] (parse-cli-opts args))
arg0 (if (:no-boot-script opts) nil arg0)
arg0 (or (:file opts) (if (:no-boot-script opts) nil arg0))
boot? (and boot? (not (:file opts)))
verbosity (if (:quiet opts)
(* -1 @util/*verbosity*)
(or (:verbose opts) 0))]
Expand Down Expand Up @@ -175,7 +180,7 @@
(reduce #(if-let [v (opts %2)] (assoc %1 %2 v) %1) {})
(merge {} (:set-env opts)))
import-ns (export-task-namespaces initial-env)
scriptforms (emit boot? args userforms localforms bootforms import-ns)
scriptforms (emit boot? args userforms localforms bootforms import-ns (:init opts))
scriptstr (binding [*print-meta* true]
(str (string/join "\n\n" (map pr-boot-form scriptforms)) "\n"))]

Expand Down
6 changes: 3 additions & 3 deletions boot/core/src/boot/task/built_in.clj
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
(string/join "\n"))))))

(core/deftask ^{:deprecated "2.6.0"} checkout
"Checkout dependencies task. DEPRECATED.
"Checkout dependencies task. DEPRECATED. (Use -c, --checkouts Boot option.)
This task facilitates working on a project and its dependencies at the same
time, by extracting the dependency jar contents into the fileset. Transitive
Expand Down Expand Up @@ -128,8 +128,8 @@
(pod/unpack-jar (.getPath file) tmp)))
(->> tmps vals (reduce adder fs) core/commit!)))))

(core/deftask speak
"Audible notifications during build.
(core/deftask ^{:deprecated "2.7.0"} speak
"Audible notifications during build. DEPRECATED. Use the notify task.
Default themes: system (the default), ordinance, pillsbury, and
woodblock. New themes can be included via jar dependency with the
Expand Down

3 comments on commit be5c751

@arichiardi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surprisingly easy to accomplish, great!

@micha
Copy link
Contributor Author

@micha micha commented on be5c751 Jul 31, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha, yeah the -main function let bindings are getting pretty hairy now...

@micha
Copy link
Contributor Author

@micha micha commented on be5c751 Jul 31, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They need a shave 💇

Please sign in to comment.