My father is a greate chef :)
Daddy is a small configuration management tool for Clojure. This project is heavily inspired by mitamae.
Download binary from releases.
curl -sfLo dad https://github.com/liquidz/daddy/releases/download/0.1.1/dad.linux-amd64
chmod +x dad
./dad your_task.clj
Here is a example to install Clojure command line tools.
#!/usr/bin/env dad --no-color --dry-run
(package ["curl" "rlwrap"])
;; You can define function as you like
(defn curl [m]
(let [{:keys [path url]} m]
;; `file-exists?` is a built-in function in daddy.
(when (and (not (file-exists? path))
(string? url))
(execute (str "curl -sfLo " path " " url)))))
(curl {:path "/tmp/install.sh"
:url "https://download.clojure.org/install/linux-install-1.10.1.489.sh"})
(file {:path "/tmp/install.sh" :mode "755"})
(execute {:cwd "/tmp" :command "./install.sh"})
(file {:path "/tmp/install.sh" :action :delete})
-
✓ Ubuntu (
apt
) -
✓ macOS (Homebrew)
Name | Var/Func | Description |
---|---|---|
env |
Var |
Map of environmental variables. E.g. |
file-exists? |
Func |
Return true if the specified path exists. |
load-file |
Func |
Load another *.clj file. E.g. |
os-type |
Func |
OS name string such as |
println |
Func |
|
str/join |
Func |
Resources are called like follows.
<main-arg>
will be associated to the main key for the resource.
(resource-name {:key :value ...})
(resource-name <main-arg> {:key :value ...})
;; E.g. following codes are equivalent because `directory` resource's main key is `path`.
(directory "foo/bar" {:owner "alice"})
(directory {:path "foo/bar" :owner "alice"})
Create directories.
Key | Value | Required | Default | Description |
---|---|---|---|---|
<path> |
String |
Yes |
Directories are created recursively. |
|
action |
Keyword or String |
No |
|
|
mode |
String |
No |
||
owner |
String |
No |
||
group |
String |
No |
(directory "foo/bar")
(directory {:path "foo/bar"})
Execute a shell command.
Key | Value | Required | Default | Description |
---|---|---|---|---|
<command> |
String |
Yes |
||
cwd |
String |
No |
Working directory. |
|
pre |
String |
No |
Pre-condition to execute |
|
pre-not |
String |
No |
Pre-condition not to execute |
(execute "curl -sfLo /tmp/foobar https://example.com")
(execute {:cwd "/tmp" :command "curl -sfLo foobar https://example.com"})
(execute {:command "touch foo" :pre-not "test -e bar"})
Create a file.
Key | Value | Required | Default | Description |
---|---|---|---|---|
<path> |
String |
Yes |
||
action |
Keyword or String |
No |
|
|
mode |
String |
No |
||
owner |
String |
No |
||
group |
String |
No |
(file "foobar" {:mode "755"})
(file {:path "foobar" :mode "755"})
Key | Value | Required | Default | Description |
---|---|---|---|---|
<path> |
String |
Yes |
||
url |
String |
Yes |
||
revision |
String |
No |
|
(git "daddy-source" {:url "https://github.com/liquidz/daddy"})
(git {:path "daddy-source" :url "https://github.com/liquidz/daddy"})
Create a symbolic link.
Key | Value | Required | Default | Description |
---|---|---|---|---|
<path> |
String |
Yes |
Link path. |
|
to |
String |
Yes |
Destination path. |
(link "~/.lein/profiles.clj" {:to "/path/to/your/dotfiles/profiles.clj"})
(link {:path "~/.lein/profiles.clj" :to "/path/to/your/dotfiles/profiles.clj"})
Install packages.
Key | Value | Required | Default | Description |
---|---|---|---|---|
<name> |
String or String list |
Yes |
||
action |
Keyword or String |
no |
|
|
(package "vim")
(package {:name "vim"})
Create a text file from the specified template files.
Key | Value | Required | Default | Description |
---|---|---|---|---|
<path> |
String |
Yes |
||
source |
String |
Yes |
Source template file. |
|
variables |
Map |
No |
|
Variables to inject to template file. |
mode |
String |
No |
||
owner |
String |
No |
||
group |
String |
No |
hello {{msg}}
(template "result.txt" {:source "source.txt" :variables {:msg "world"}})
(template {:path "result.txt" :source "source.txt" :variables {:msg "world"}})
Copyright © 2019 Masashi Iizuka
This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0.
This Source Code may also be made available under the following Secondary Licenses when the conditions for such availability set forth in the Eclipse Public License, v. 2.0 are satisfied: GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version, with the GNU Classpath Exception which is available at https://www.gnu.org/software/classpath/license.html.