act.handler.CliHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of act Show documentation
Show all versions of act Show documentation
The ACT full stack MVC framework
package act.handler;
/*-
* #%L
* ACT Framework
* %%
* Copyright (C) 2014 - 2017 ActFramework
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import act.Act;
import act.Destroyable;
import act.cli.CliContext;
import act.cli.CliSession;
import org.osgl.$;
import java.util.List;
/**
* Defines a thread-save function object that can be applied
* to a {@link CliContext} context to
* produce certain output which could be applied to cli
* associated with the context
*/
public interface CliHandler extends $.Function, Destroyable {
/**
* Invoke handler upon a cli context
*
* @param context the cli context
*/
void handle(CliContext context);
/**
* Returns the command line information that is used to display the
* command in help. For example the {@link act.cli.builtin.Help} command is
*
* help [options] [command] show help message
*
* So the method of {@code Help} command should return
*
* $.T2("help [options] [command]", "show help message")
*
* @return the command line
*/
$.T2 commandLine();
/**
* Returns the summary of the command. This is used to display the help information
* about this command. If null
or empty string returned, then there will
* be no summary section in the help for this command
* @return the command summary
*/
String summary();
/**
* Returns a list of options information to be displayed in help of
* this command. E.g. the options of {@link act.cli.builtin.Help} command
* is
*
* -s --system list system commands
* -a --app list app commands
*
* Then the method of {@code Help} should return a list of
*
* $.T2("-s --system", "list system commands")
* $.T2("-a --app", "list application commands")
*
*
* @return the options information about this command
*/
List<$.T2> options();
/**
* Check if this handler applied in a specific {@link act.Act.Mode}
* @return {@code true} if this handler applied in the mode, or {@code false} otherwise
*/
boolean appliedIn(Act.Mode mode);
/**
* Reset session cursor
* @param session CLI session
*/
void resetCursor(CliSession session);
}