view src/main/java/org/icedrobot/ika/plugins/help/IkaVersion.java @ 8:b2827d00500a

Mavenize IKA.
author Roman Kennke <roman.kennke@sun.com>
date Wed, 16 Mar 2011 22:47:21 +0100
parents src/org/icedrobot/ika/plugins/help/IkaVersion.java@838c5ed93dd6
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.help;

import joptsimple.OptionParser;
import joptsimple.OptionSet;
import org.icedrobot.ika.Ika;
import org.icedrobot.ika.plugins.IkaPlugin;
import org.icedrobot.ika.plugins.IkaPluginResult;

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

    private static final String VERSION_INFO =
            "ika: IcedRobot Kiosk Application version " + Ika.VERSION;

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

        if (args != null) {

            OptionParser parser = new OptionParser();
            parser.accepts("list-plugins");
            parser.accepts("version");

            OptionSet options = parser.parse(args);

            if (options.has("list-plugins")) {
                for (IkaPlugin plugin : Ika.getInstance().getPlugins().values())
                {
                    System.out.println("  " + plugin.getName() + ":\n\t\t" +
                                       plugin.getDescription());
                }
                System.out.println("");
            }
        }
        
        System.out.println(VERSION_INFO);

        return IkaPluginResult.OK;
    }

    @Override
    public String getDescription() {
        return "display version information and return";
    }

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