Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display panc version in command line utilities and Ant API #75

Merged
merged 2 commits into from
Oct 22, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion panc/src/main/clojure/org/quattor/pan/pan_annotations.clj
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ Usage: panc-annotations [options] files
["-v" "--verbose" "verbosity level; may be specified multiple times to increase value"
:default 0
:assoc-fn (fn [m k _] (update-in m [k] inc))]
[nil "--version" "show pan compiler version"
:default false
:flag true]
["-h" "--help" "print help message"
:default false
:flag true]])
Expand All @@ -76,6 +79,10 @@ Usage: panc-annotations [options] files
[options-summary]
(format usage-fmt options-summary))

(defn compiler-version []
(println "pan compiler version:" (org.quattor.pan.Compiler/version))
(System/exit 0))

(defn error-msg
[errors]
(str "The following errors occurred while parsing your command:\n\n"
Expand All @@ -90,9 +97,10 @@ Usage: panc-annotations [options] files
[& args]

(let [{:keys [options arguments errors summary]} (parse-opts args cli-options)]
(let [{:keys [help verbose quiet]} options]
(let [{:keys [help verbose version quiet]} options]
(cond
help (exit 0 (usage summary))
version (compiler-version)
(zero? (count args)) (exit 1 (usage summary))
errors (exit 1 (str (error-msg errors) "\n\n" (usage summary))))
(when (pos? verbose)
Expand Down
6 changes: 6 additions & 0 deletions panc/src/main/clojure/org/quattor/pan/pan_compiler.clj
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ Please file a bug report including the stack trace.
[nil "--log-file FILE" "specify log file"]
[nil "--warnings FLAG" "off, on, fatal" :default "on"]
["-v" "--verbose" "show statistics and progress" :default false :flag true]
[nil "--version" "show pan compiler version" :default false :flag true]
["-h" "--help" "print command help" :default false :flag true]])

(defn banner-and-exit [banner]
Expand All @@ -113,6 +114,10 @@ Please file a bug report including the stack trace.
(println (format-ex-info e))
(System/exit 1))

(defn compiler-version []
(println "pan compiler version:" (org.quattor.pan.Compiler/version))
(System/exit 0))

(defn build-profiles [options pan-sources]
(let [compiler-options (create-compiler-options)]
(org.quattor.pan.Compiler/run compiler-options nil pan-sources)))
Expand Down Expand Up @@ -143,6 +148,7 @@ Please file a bug report including the stack trace.
(let [{:keys [options arguments errors summary]} (cli/parse-opts args cli-args)]
(cond
(:help options) (banner-and-exit summary)
(:version options) (compiler-version)
errors (error-message errors)
:else (run-compiler options arguments)))
(catch ExceptionInfo e
Expand Down
43 changes: 43 additions & 0 deletions panc/src/main/java/org/quattor/ant/PanCompilerVersion.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
Copyright (c) 2006-2012 Centre National de la Recherche Scientifique (CNRS).
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package org.quattor.ant;

import java.io.File;
import java.util.LinkedList;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.FileSet;
import org.quattor.pan.Compiler;

/**
* An ant task which displays the pan compiler version.
*
* @author Michel Jouvin
*
*/
public class PanCompilerVersion extends Task {

@Override
public void execute() throws BuildException {

this.log("pan compiler version: "+Compiler.version);

}

}
1 change: 1 addition & 0 deletions panc/src/main/resources/org/quattor/ant/panc-ant.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@
<taskdef name="panc" classname="org.quattor.ant.PanCompilerTask"/>
<taskdef name="panc-check-syntax" classname="org.quattor.ant.PanCheckSyntaxTask"/>
<taskdef name="panc-annotations" classname="org.quattor.ant.PanAnnotationsTask"/>
<taskdef name="panc-version" classname="org.quattor.ant.PanCompilerVersion"/>
</antlib>