Giter Site home page Giter Site logo

liquidz / dad Goto Github PK

View Code? Open in Web Editor NEW
129.0 6.0 7.0 250 KB

Small configuration management tool for Clojure

License: Eclipse Public License 2.0

Makefile 3.54% Clojure 86.46% Shell 9.66% Dockerfile 0.33%
clojure infrastructure-as-code graalvm

dad's Introduction

Dad

badge badge badge dad

My father is a greate chef :)

Dad is a small configuration management tool for Clojure. This project is heavily inspired by mitamae.

Concept

๐Ÿคฏ Minimum to remember

  • May not write code for Dad often.

  • Write codes as a babashka pod.

    • You can gain benefits from code completion and docstring references.

๐ŸŸ Easy to start

  • Download single binary and run it.

  • Run the code written as a babashka pod as it is.

    • Dad ignores codes related to loading pods.

Getting Started

Download binary from releases.

# Download latest dad to the current working directory
curl -L https://raw.githubusercontent.com/liquidz/dad/main/script/download | bash
./dad your_task.clj

Here is a example to install Clojure command line tools.

You can generate a template file by ./dad --init example.core.

#!/usr/bin/env dad --no-color --dry-run
(ns example.core
  (:require
   [babashka.pods :as pods]))

;; Load dad as a babashka pod
(pods/load-pod "dad")
(require '[pod.liquidz.dad :as dad])

(dad/package {:name ["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 dad.
    (when (and (not (dad/file-exists? path))
               (string? url))
      (dad/execute {:command (str "curl -sfLo " path " " url)}))))

(curl {:path "/tmp/install.sh"
       :url "https://download.clojure.org/install/linux-install-1.10.3.1087.sh"})

(dad/file {:path "/tmp/install.sh" :mode "755"})
(dad/execute {:cwd "/tmp" :command "./install.sh"})
(dad/file {:path "/tmp/install.sh" :action :delete})

Supports

  • โœ“ Ubuntu (apt)

  • โœ“ macOS (Homebrew)

Reference

Note
You can refer all documents in codes. (evaluate (dad/doc) or (help))

Built-in vars / functions

Name Var/Func Description

doc

Func

Print dad documents.

file-exists?

Func

Return true if the specified path exists.

os-type

Func

OS name string such as "linux" or "mac".

render

Func

Render a template string with a data.

load-file

Func

Load another recipe file.

See sci/impl/namespaces.cljc for other core functions.

Resources

Resource name Description

directory

Create directories.

download

Download a file from remote host.

execute

Execute a shell command.

file

Create a file.

git

Execute git command.

link

Create a symbolic link.

package

Install packages.

template

Create a text file from the specified template files.

REPL

Dad also provides REPL mode that does not affect your environment. (same as --dry-run option)

$ dad --repl

user=> (println "hello from dad")
hello from dad
nil

user=> (+ 1 2 3)
6

user=> (package "sl")
apt-update [sl] ... will change
package-install [sl] ... will change

user=> (package "sl" {:action :uninstall})
package-uninstall [sl] ... WILL NOT change

License

Copyright ยฉ 2019-2022 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.

dad's People

Contributors

borkdude avatar burinc avatar liquidz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

dad's Issues

Expand var in string

It is boring to wrap with str everytime.

(def src-dir "/usr/local/src")

::: boring
(git {:path (str src-dir "/vim")
      :url "https://github.com/vim/vim"})

::: best
(git {:path "{{src-dir}}/vim"
      :url "https://github.com/vim/vim"})

:: better
(git {:path (render "{{src-dir}}/vim" {:src-dir src-dir})
      :url "https://github.com/vim/vim"})

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.