view src/main/java/org/icedrobot/ika/plugins/scm/IkaPatchQueueHandler.java @ 18:9c7b23248996

Add new plugins to handle guilt patch queue.
author Mario Torre <neugens.limasoftware@gmail.com>
date Tue, 05 Apr 2011 23:03:18 +0200
parents
children
line wrap: on
line source

/*
 * IKA - IcedRobot Kiosk Application
 * Copyright (C) 2011  IcedRobot team
 *
 * 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 3 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, see <http://www.gnu.org/licenses/>.
 */
package org.icedrobot.ika.plugins.scm;

import java.io.IOException;
import joptsimple.OptionParser;
import org.icedrobot.ika.plugins.IkaPlugin;

/**
 */
abstract class IkaPatchQueueHandler implements IkaPlugin {

    static OptionParser parser;

    static {
        parser = new OptionParser() {
            {
                accepts(PatchQueueOption.HELP.getOption(),
                        PatchQueueOption.HELP.getDescription());
                accepts(PatchQueueOption.FORCE.getOption(),
                        PatchQueueOption.FORCE.getDescription());
                accepts(PatchQueueOption.ALL.getOption(),
                        PatchQueueOption.ALL.getDescription());
            }
        };
    }

    abstract protected boolean hasArgument();

    protected void displayUsage() {
        String fileName = "name.patch";
        if (hasArgument()) {
            fileName = "";
        }
        System.out.println("ika " + getName() + " [-f] " + fileName);
        System.out.println(getDescription());
        try {
            parser.printHelpOn(System.out);

        } catch (IOException ignore) {}
    }
}