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.shell.io.ShellPrinter;
023    
024    import java.util.Map;
025    
026    /**
027     * <p>The shell command allows a single source to provide a customized invoker according to the context
028     * of the arguments. More importantly it allows to decouple the obtention of a command related to its
029     * arguments from the actual execution of the command. This somewhat matters because the command execution
030     * pipeline has notion of consumed and produced types, thanks to this, the consumed and produced
031     * types can vary according to the arguments.</p>
032     *
033     * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
034     * @version $Revision$
035     */
036    public interface ShellCommand {
037    
038      /**
039       * Provide completions for the specified arguments.
040       *
041       * @param context the command context
042       * @param line the original command line arguments
043       * @return the completions
044       */
045      Map<String, String> complete(CommandContext context, String line);
046    
047      /**
048       * Returns a description of the command or null if none can be found.
049       *
050       * @param line the usage line
051       * @param mode the description mode
052       * @return the description
053       */
054      String describe(String line, DescriptionMode mode);
055    
056      /**
057       * Provides an invoker for the specified arguments.
058       *
059       * @param line the command line arguments
060       * @return the command to provide
061       */
062      CommandInvoker<?, ?> createInvoker(String line);
063    
064    }