view src/org/icedrobot/ika/plugins/git/IkaGitWrapper.java @ 6:2bd34951aadf

add new plugin.
author Mario Torre <neugens.limasoftware@gmail.com>
date Wed, 09 Mar 2011 00:40:02 +0100
parents
children 4e841dd81d28
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.git;

import java.io.File;
import joptsimple.OptionParser;
import joptsimple.OptionSet;
import org.icedrobot.ika.plugins.IkaPlugin;
import org.icedrobot.ika.plugins.IkaPluginResult;
import org.icedrobot.ika.plugins.scm.GITRepository;
import org.icedrobot.ika.plugins.scm.Repository;

/**
 * @author Mario Torre <neugens.limasoftware@gmail.com>
 */
public class IkaGitWrapper implements IkaPlugin {

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

    @Override
    public String getDescription() {
        return "handles various git tasks for IcedRobot";
    }

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

        if (args != null) {
            OptionParser parser = new OptionParser();
            parser.accepts("makerepo").withRequiredArg();
            
            OptionSet options = parser.parse(args);
        
            if (options.has("makerepo")) {
                String destinationDir = (String) options.valueOf("makerepo");

                File base = new File(destinationDir);
                if (!base.exists()) {
                    System.out.println("desitination directory doesn't exist");
                    return IkaPluginResult.FAILURE;
                }

                System.err.println("base.getName(): " + base.getName());
                GITRepository repository = new GITRepository(base.getName(), base,
                                                          "", "", "icedrobot");
                repository.create();
            }
        }
        return IkaPluginResult.OK;
    }
}