|
1 | 1 | (ns drift.generator |
2 | | - (:require [drift.args :as args] |
| 2 | + (:require [clojure.string :as string] |
| 3 | + [clojure.tools.logging :as logging] |
| 4 | + [drift.args :as args] |
3 | 5 | [drift.builder :as builder] |
4 | | - [drift.core :as core] |
5 | | - [drift.config :as config])) |
| 6 | + [drift.config :as config] |
| 7 | + [drift.core :as core])) |
6 | 8 |
|
7 | 9 | (defn |
8 | 10 | #^{ :doc "Prints out how to use the generate migration command." } |
|
13 | 15 | (defn |
14 | 16 | create-file-content [migration-namespace ns-content up-content down-content] |
15 | 17 | (let [migration-number (core/migration-number-from-namespace migration-namespace)] |
16 | | - (str "(ns " migration-namespace (or ns-content (config/default-ns-content)) ") |
| 18 | + (str "(ns " migration-namespace (or ns-content (config/default-ns-content)) ") |
17 | 19 |
|
18 | 20 | (defn up |
19 | 21 | \"Migrates the database up to version " migration-number ".\" |
|
49 | 51 | "parse command-line args from lein, set up any custom config, |
50 | 52 | and invoke generate-migration-file" |
51 | 53 | [args] |
52 | | - (let [[opts remaining] (args/parse-create-migration-args args) |
53 | | - migration-name (first remaining)] |
54 | | - (config/with-config-fn-symbol (:config opts) |
55 | | - (fn [] |
56 | | - (generate-migration-file migration-name))))) |
| 54 | + (let [[opts [migration-name & remaining]] (args/parse-create-migration-args args)] |
| 55 | + (if (empty? remaining) |
| 56 | + (config/with-config-fn-symbol |
| 57 | + (:config opts) |
| 58 | + (fn [] |
| 59 | + (generate-migration-file migration-name))) |
| 60 | + (do (logging/error "Invalid arguments:" (string/join " " remaining)) |
| 61 | + (args/print-usage "create-migration" args/create-migration-arg-specs "migration-name"))))) |
0 commit comments