Skip to content
Permalink
Browse files

Added -V/--version support

  • Loading branch information
davglass committed Jul 10, 2012
1 parent e850739 commit cbf181dd9b5d9325eff51468c9a14e303bb32948
Showing with 30 additions and 4 deletions.
  1. +16 −3 build.xml
  2. +14 −1 src/com/yahoo/platform/yui/compressor/YUICompressor.java
@@ -10,17 +10,30 @@
</target>

<target name="-init" depends="-load.properties">
<delete dir="${build.dir}"/>
<mkdir dir="${build.dir}"/>
</target>

<target name="build.classes" depends="-init">
<target name="-updateversion" depends="-init">
<copy todir="${build.dir}/build_tmp">
<fileset dir="${src.dir}"/>
<filterchain>
<replacetokens>
<token key="VERSION" value="${version.number}"/>
</replacetokens>
</filterchain>
</copy>
</target>

<target name="build.classes" depends="-init, -updateversion">
<mkdir dir="${build.dir}/classes"/>
<javac srcdir="${src.dir}"
<javac srcdir="${build.dir}/build_tmp"
destdir="${build.dir}/classes"
includes="**/*.java"
deprecation="off"
debug="on"
target="1.5"
includeantruntime="false"
target="1.5"
source="1.5">
<classpath>
<pathelement location="${lib.dir}/jargs-1.0.jar"/>
@@ -21,6 +21,7 @@ public static void main(String args[]) {

CmdLineParser parser = new CmdLineParser();
CmdLineParser.Option typeOpt = parser.addStringOption("type");
CmdLineParser.Option versionOpt = parser.addBooleanOption('V', "version");
CmdLineParser.Option verboseOpt = parser.addBooleanOption('v', "verbose");
CmdLineParser.Option nomungeOpt = parser.addBooleanOption("nomunge");
CmdLineParser.Option linebreakOpt = parser.addStringOption("line-break");
@@ -43,6 +44,12 @@ public static void main(String args[]) {
System.exit(0);
}

Boolean version = (Boolean) parser.getOptionValue(versionOpt);
if (version != null && version.booleanValue()) {
version();
System.exit(0);
}

boolean verbose = parser.getOptionValue(verboseOpt) != null;

String charset = (String) parser.getOptionValue(charsetOpt);
@@ -228,11 +235,17 @@ public EvaluatorException runtimeError(String message, String sourceName,
}
}

private static void version() {
System.err.println("@VERSION@");
}
private static void usage() {
System.err.println(
"\nUsage: java -jar yuicompressor-2.4.6.jar [options] [input file]\n\n"
"YUICompressor Version: @VERSION@\n"

+ "\nUsage: java -jar yuicompressor-@VERSION@.jar [options] [input file]\n"
+ "\n"
+ "Global Options\n"
+ " -V, --version Print version information\n"
+ " -h, --help Displays this information\n"
+ " --type <js|css> Specifies the type of the input file\n"
+ " --charset <charset> Read the input file using <charset>\n"

0 comments on commit cbf181d

Please sign in to comment.
You can’t perform that action at this time.