view src/main/java/org/icedrobot/ika/plugins/scm/IkaPatchQueueNew.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.util.List;
import joptsimple.OptionSet;
import org.icedrobot.ika.plugins.IkaPluginResult;
import org.icedrobot.ika.runtime.scm.GITPatchQueue;

/**
 * Handles patch queues in IcedRobot, abstracting the underliying patch queue
 * system.
 *
 * This is the implementation of the qnew command.
 */
public class IkaPatchQueueNew extends IkaPatchQueueHandler {

    @Override
    public String getName() {
        return "qnew";
    }

    @Override
    public String getDescription() {
        return "creates a new ika managed patch in the patch queue";
    }

    @Override
    public IkaPluginResult execute(String[] args) {

        OptionSet options = parser.parse(args);
        if (options.has(PatchQueueOption.HELP.getOption())) {
            displayUsage();
        } else {

            boolean force = options.has(PatchQueueOption.FORCE.getOption());
            List<String> files = options.nonOptionArguments();
            if (files.size() != 2) {
                displayUsage();
            } else {
                GITPatchQueue.newPatch(files.get(1), force);
            }
        }
            
        return IkaPluginResult.OK;
    }

    @Override
    protected boolean hasArgument() {
        return true;
    }
}