001/* 002 * (C) Copyright 2006-2010 Nuxeo SAS (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * bstefanescu 016 */ 017package org.nuxeo.shell.equinox.cmds; 018 019import org.nuxeo.shell.Argument; 020import org.nuxeo.shell.Command; 021import org.nuxeo.shell.Context; 022import org.nuxeo.shell.Shell; 023import org.nuxeo.shell.cmds.Interactive; 024import org.nuxeo.shell.equinox.Connector; 025import org.nuxeo.shell.equinox.EquinoxCommandCompletor; 026 027/** 028 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a> 029 */ 030@Command(name = "run", help = "Run an Equinox command") 031public class Run implements Runnable { 032 033 @Context 034 protected Shell shell; 035 036 @Context 037 protected Connector connector; 038 039 @Argument(name = "cmd", index = 0, completor = EquinoxCommandCompletor.class, help = "The command to run. If not specified the list of all commands is displayed.") 040 protected String cmd; 041 042 @Argument(name = "cmd arg1", index = 1, help = "Command argument") 043 protected String arg1; 044 045 @Argument(name = "cmd arg2", index = 2, help = "Command argument") 046 protected String arg2; 047 048 @Argument(name = "cmd arg3", index = 3, help = "Command argument") 049 protected String arg3; 050 051 @Argument(name = "cmd arg4", index = 4, help = "Command argument") 052 protected String arg4; 053 054 @Argument(name = "cmd arg5", index = 5, help = "Command argument") 055 protected String arg5; 056 057 @Argument(name = "cmd arg6", index = 6, help = "Command argument") 058 protected String arg6; 059 060 public void run() { 061 if (cmd == null) { 062 cmd = "help"; 063 } else { 064 cmd = Interactive.getCurrentCmdLine().trim(); 065 cmd = cmd.substring("run".length()).trim(); 066 } 067 shell.getConsole().println(connector.send(cmd)); 068 } 069}