Lein-LB / src / leiningen / lb.clj

shantanuk 751b803 

(ns leiningen.lb
  (:require [clojure.contrib.duck-streams :as ds]))

(def *version* "0.1-SNAPSHOT (uses Liquibase 2.0-RC6)")

;; DSL

(defn help
    (str "
Lein-LB - Lein Liquibase plugin " *version* "

For help on Liquibase commands:

    $ lein lb help

Lein-LB commands (they all begin with a colon):
    :help               prints this help screen
    :sample-properties  prints sample properties to put in liquibase.properties

(defn sample-props
  (let [filename "/liquibase.properties"
        istream  (.getResourceAsStream String filename)
        owriter  (java.io.StringWriter.)]
    ;; InputStream resourceAsStream = getClass().getResourceAsStream("/mypackage/mysubpackage/myfile.txt");
    (ds/copy istream owriter)
    (println (.toString owriter))))

(defn execute-liquibase-cmd
  "Execute Liquibase as if using command-line arguments (String array)"
  (liquibase.integration.commandline.Main/main argv))

;; ----- Leiningen plugin command -----

(defn lb
  [& args]
  (let [argc (count args)
        argv (into-array String args)
        cmd  (first args)]
    ;; check for lein-lb commands
      (empty? args)                (help)
      (= cmd ":help")              (help)
      (= cmd ":sample-properties") (sample-props)
      :else                        (execute-liquibase-cmd argv))))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.