2 * Copyright 2012 Take-Yuki NAGAO
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package jp.sourceforge.dvibrowser.dvi2epub.cmd;
19 import java.io.PrintWriter;
21 public abstract class AnnotatedCommand extends AbstractCommand {
22 private CommandLineParser parser;
23 private boolean wantHelp;
24 private String[] args;
26 public AnnotatedCommand() {
27 parser = new AnnotatedCommandLineParser(this);
30 @BooleanValueOption(shortName = "h", longName = "help", description = "Show help")
31 public void wantHelp(boolean want) {
35 public boolean wantHelp() {
40 public int execute(String[] args) throws CommandException {
43 int ret = doProcessCommandLine();
46 PrintWriter out = getWriter();
53 protected int doProcessCommandLine()
54 throws CommandException {
57 return Command.EXIT_SUCCESS;
59 return processCommandLine();
63 protected abstract int processCommandLine() throws CommandException;
66 public void showUsage(PrintWriter pw) throws CommandException {
72 public String getApplicationName() throws CommandException {
73 return getClass().getName();
76 public String[] getArgs() {
80 public void setArgs(String[] args) {
84 protected OptionMapper createOptionMapper(ParserState state) {
85 return new DefaultOptionMapper(state);