001/* 002 * Copyright 2012-2017 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.boot.cli.command; 018 019import java.util.Collection; 020 021import org.springframework.boot.cli.command.options.OptionHelp; 022import org.springframework.boot.cli.command.status.ExitStatus; 023 024/** 025 * A single command that can be run from the CLI. 026 * 027 * @author Phillip Webb 028 * @author Dave Syer 029 * @author Stephane Nicoll 030 * @see #run(String...) 031 */ 032public interface Command { 033 034 /** 035 * Returns the name of the command. 036 * @return the command's name 037 */ 038 String getName(); 039 040 /** 041 * Returns a description of the command. 042 * @return the command's description 043 */ 044 String getDescription(); 045 046 /** 047 * Returns usage help for the command. This should be a simple one-line string 048 * describing basic usage. e.g. '[options] <file>'. Do not include the name of 049 * the command in this string. 050 * @return the command's usage help 051 */ 052 String getUsageHelp(); 053 054 /** 055 * Gets full help text for the command, e.g. a longer description and one line per 056 * option. 057 * @return the command's help text 058 */ 059 String getHelp(); 060 061 /** 062 * Returns help for each supported option. 063 * @return help for each of the command's options 064 */ 065 Collection<OptionHelp> getOptionsHelp(); 066 067 /** 068 * Return some examples for the command. 069 * @return the command's examples 070 */ 071 Collection<HelpExample> getExamples(); 072 073 /** 074 * Run the command. 075 * @param args command arguments (this will not include the command itself) 076 * @return the outcome of the command 077 * @throws Exception if the command fails 078 */ 079 ExitStatus run(String... args) throws Exception; 080 081}