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; 018 019import java.util.List; 020import java.util.Map; 021 022import jline.Completor; 023 024/** 025 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a> 026 */ 027public interface CommandType extends Comparable<CommandType> { 028 029 Class<?> getCommandClass(); 030 031 String getHelp(); 032 033 String getName(); 034 035 String[] getAliases(); 036 037 List<Token> getArguments(); 038 039 Map<String, Token> getParameters(); 040 041 String getSyntax(); 042 043 Runnable newInstance(Shell shell, String... line) throws ShellException; 044 045 Completor getLastTokenCompletor(Shell shell, String... line); 046 047 interface Setter { 048 Class<?> getType(); 049 050 void set(Object obj, Object value) throws ShellException; 051 } 052 053 class Token implements Comparable<Token> { 054 055 public String name; 056 057 public int index = -1; 058 059 public String help; 060 061 // for params required means value is required 062 public boolean isRequired; 063 064 public Setter setter; 065 066 public Class<? extends Completor> completor; 067 068 public boolean isArgument() { 069 return index > -1; 070 } 071 072 public int compareTo(Token o) { 073 return index - o.index; 074 } 075 076 } 077 078}