From 1338b548463e041fd2d5e47a19a8febbdcde2347 Mon Sep 17 00:00:00 2001 From: Simon Brooke Date: Mon, 11 Jun 2018 01:34:03 +0100 Subject: [PATCH] Added a main class, to allow command line invocation. --- RELEASENOTES.md | 8 ++++++ project.clj | 10 ++++--- src/adl/main.clj | 50 +++++++++++++++++++++++++++++++++ src/adl/to_hugsql_queries.clj | 4 --- src/adl/to_json_routes.clj | 3 +- src/adl/to_selmer_routes.clj | 5 ---- src/adl/to_selmer_templates.clj | 11 +------- src/adl/utils.clj | 11 ++++++++ 8 files changed, 78 insertions(+), 24 deletions(-) create mode 100644 src/adl/main.clj diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 7adf8c0..2cb9c4c 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -1,3 +1,11 @@ +# Release 1.4.1 + +Release 1.4.1 adds a 'magnitude' element to entities, in order to provide a pragma for when +to switch to asynchronous select widgets. + +It also provides a family of transforms, written in Clojure, to generate a skeleton Clojure +web app from an ADL specification. + # Release 1.4 Release 1.4 adds an 'order' element as a possible child of the 'list' element, in order to specify diff --git a/project.clj b/project.clj index 945cda4..131722c 100644 --- a/project.clj +++ b/project.clj @@ -1,10 +1,12 @@ -(defproject adl "0.1.0-SNAPSHOT" - :description "FIXME: write description" +(defproject adl "1.4.1-SNAPSHOT" + :description "An application to transform an ADL application specification document into skeleton code for a Clojure web-app" :url "http://example.com/FIXME" - :license {:name "Eclipse Public License" - :url "http://www.eclipse.org/legal/epl-v10.html"} + :license {:name "GNU General Public License,version 2.0 or (at your option) any later version" + :url "https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html"} :dependencies [[org.clojure/clojure "1.8.0"] [org.clojure/math.combinatorics "0.1.4"] [bouncer "1.0.1"] [hiccup "1.0.5"]] + :aot [adl.main] + :main adl.main :plugins [[lein-codox "0.10.3"]]) diff --git a/src/adl/main.clj b/src/adl/main.clj new file mode 100644 index 0000000..d56e945 --- /dev/null +++ b/src/adl/main.clj @@ -0,0 +1,50 @@ +(ns ^{:doc "Application Description Language - command line invocation." + :author "Simon Brooke"} + adl.main + (:require [adl.utils :refer :all] + [adl.to-hugsql-queries :as h] + [adl.to-json-routes :as j] + [adl.to-selmer-routes :as s] + [adl.to-selmer-templates :as t] + [clojure.xml :as x]) + (:gen-class)) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;; +;;;; adl.main +;;;; +;;;; This program is free software; you can redistribute it and/or +;;;; modify it under the terms of the GNU General Public License +;;;; as published by the Free Software Foundation; either version 2 +;;;; of the License, or (at your option) any later version. +;;;; +;;;; This program is distributed in the hope that it will be useful, +;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;;; GNU General Public License for more details. +;;;; +;;;; You should have received a copy of the GNU General Public License +;;;; along with this program; if not, write to the Free Software +;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +;;;; USA. +;;;; +;;;; Copyright (C) 2018 Simon Brooke +;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defn print-usage [_] + (println "Argument should be a pathname to an ADL file")) + +(defn -main + "Expects as arg the name of the git hook to be handled, followed by the arguments to it" + [& args] + (cond + (empty? args) + (print-usage args) + (.exists (java.io.File. (first args))) + (let [application (x/parse (first args))] + (h/to-hugsql-queries application) + ;; (j/to-json-routes application) + (s/to-selmer-routes application) + (t/to-selmer-templates application)))) + diff --git a/src/adl/to_hugsql_queries.clj b/src/adl/to_hugsql_queries.clj index ee44fe1..c9633d7 100644 --- a/src/adl/to_hugsql_queries.clj +++ b/src/adl/to_hugsql_queries.clj @@ -33,10 +33,6 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(def ^:dynamic *output-path* - "The path to which generated files will be written." - "resources/auto/") - (defn where-clause "Generate an appropriate `where` clause for queries on this `entity`; if `properties` are passed, filter on those properties, otherwise the key diff --git a/src/adl/to_json_routes.clj b/src/adl/to_json_routes.clj index 97e015c..a6daf18 100644 --- a/src/adl/to_json_routes.clj +++ b/src/adl/to_json_routes.clj @@ -4,7 +4,8 @@ (:require [clojure.java.io :refer [file]] [clojure.string :as s] [clj-time.core :as t] - [clj-time.format :as f])) + [clj-time.format :as f] + [adl.utils :refer :all])) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; diff --git a/src/adl/to_selmer_routes.clj b/src/adl/to_selmer_routes.clj index deae446..f30c20e 100644 --- a/src/adl/to_selmer_routes.clj +++ b/src/adl/to_selmer_routes.clj @@ -34,11 +34,6 @@ ;;; Generally. there's one route in the generated file for each Selmer template which has been generated. -(def ^:dynamic *output-path* - "The path to which generated files will be written." - "resources/auto/") - - (defn file-header [application] (list diff --git a/src/adl/to_selmer_templates.clj b/src/adl/to_selmer_templates.clj index d69f9f6..874204f 100644 --- a/src/adl/to_selmer_templates.clj +++ b/src/adl/to_selmer_templates.clj @@ -1,4 +1,4 @@ -(ns ^{;; :doc "Application Description Language - generate Selmer templates for the HTML pages implied by an ADL file." +(ns ^{:doc "Application Description Language - generate Selmer templates for the HTML pages implied by an ADL file." :author "Simon Brooke"} adl.to-selmer-templates (:require [adl.utils :refer :all] @@ -34,15 +34,6 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(def ^:dynamic *locale* - "The locale for which files will be generated." - "en-GB") - -(def ^:dynamic *output-path* - "The path to which generated files will be written." - "resources/auto/") - - (defn big-link [content url] {:tag :div diff --git a/src/adl/utils.clj b/src/adl/utils.clj index 4856a77..ebd6af8 100644 --- a/src/adl/utils.clj +++ b/src/adl/utils.clj @@ -26,6 +26,17 @@ ;;;; ;;;; Copyright (C) 2018 Simon Brooke ;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + +(def ^:dynamic *locale* + "The locale for which files will be generated." + "en-GB") + +(def ^:dynamic *output-path* + "The path to which generated files will be written." + "resources/auto/") + (defn link-table-name "Canonical name of a link table between entity `e1` and entity `e2`."