01: /*
02: * Copyright 2006 Google Inc.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License. You may obtain a copy of
06: * the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13: * License for the specific language governing permissions and limitations under
14: * the License.
15: */
16: package com.google.gwt.dev.util.arg;
17:
18: import com.google.gwt.dev.jjs.JJSOptions;
19: import com.google.gwt.dev.jjs.JsOutputOption;
20: import com.google.gwt.util.tools.ArgHandler;
21:
22: /**
23: * Argument handler for processing the script style flag.
24: */
25: public final class ArgHandlerScriptStyle extends ArgHandler {
26:
27: private final JJSOptions optionsToModify;
28:
29: public ArgHandlerScriptStyle(JJSOptions optionsToModify) {
30: this .optionsToModify = optionsToModify;
31: }
32:
33: public String[] getDefaultArgs() {
34: return new String[] { "-style", "obfuscate" };
35: }
36:
37: public String getPurpose() {
38: return "Script output style: OBF[USCATED], PRETTY, or DETAILED (defaults to OBF)";
39: }
40:
41: public String getTag() {
42: return "-style";
43: }
44:
45: public String[] getTagArgs() {
46: return new String[] { "style" };
47: }
48:
49: public int handle(String[] args, int startIndex) {
50: if (startIndex + 1 < args.length) {
51: String style = args[startIndex + 1].toLowerCase();
52: if (style.startsWith("obf")) {
53: optionsToModify.setOutput(JsOutputOption.OBFUSCATED);
54: return 1;
55: } else if ("pretty".equals(style)) {
56: optionsToModify.setOutput(JsOutputOption.PRETTY);
57: return 1;
58: } else if ("detailed".equals(style)) {
59: optionsToModify.setOutput(JsOutputOption.DETAILED);
60: return 1;
61: }
62: }
63:
64: System.err.println(getTag() + " should be followed by one of");
65: System.err.println(" OBF, PRETTY, or DETAILED");
66: return -1;
67: }
68: }
|