001 /* 002 * Copyright (C) 2010 eXo Platform SAS. 003 * 004 * This is free software; you can redistribute it and/or modify it 005 * under the terms of the GNU Lesser General Public License as 006 * published by the Free Software Foundation; either version 2.1 of 007 * the License, or (at your option) any later version. 008 * 009 * This software 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 * You should have received a copy of the GNU Lesser General Public 015 * License along with this software; if not, write to the Free 016 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 017 * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 018 */ 019 020 package org.crsh.command; 021 022 import org.crsh.cmdline.CommandCompletion; 023 024 /** 025 * <p>The shell command allows a single source to provide a customized invoker according to the context 026 * of the arguments. More importantly it allows to decouple the obtention of a command related to its 027 * arguments from the actual execution of the command. This somewhat matters because the command execution 028 * pipeline has notion of consumed and produced types, thanks to this, the consumed and produced 029 * types can vary according to the arguments.</p> 030 * 031 * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a> 032 * @version $Revision$ 033 */ 034 public interface ShellCommand { 035 036 /** 037 * Provide completions for the specified arguments. 038 * 039 * @param context the command context 040 * @param line the original command line arguments 041 * @return the completions 042 */ 043 CommandCompletion complete(CommandContext context, String line); 044 045 /** 046 * Returns a description of the command or null if none can be found. 047 * 048 * @param line the usage line 049 * @param mode the description mode 050 * @return the description 051 */ 052 String describe(String line, DescriptionFormat mode); 053 054 /** 055 * Provides an invoker for the specified arguments. 056 * 057 * @param line the command line arguments 058 * @return the command to provide 059 */ 060 CommandInvoker<?, ?> createInvoker(String line); 061 062 }