org.apache.ignite.internal.commandline

## Interface Command<T>

Type Parameters:
  `T` - Generic for getArg method which should return command-specific paramters which it would be run with.

All Known Implementing Classes:
  ActivateCommand, BaselineCommand, CacheCommands, CacheContention, CacheDistribution, CacheValidateIndexes, CacheViewer, CheckIndexInlineSizes, ClusterChangeTagCommand, ClusterStateChangeCommand, DeactivateCommand, DiagnosticCommand, EncryptionCommand, FindAndDeleteGarbage, IdleVerify, KillCommand, MetadataAbstractSubCommand, MetadataCommand, MetadataDetailsCommand, MetadataHelpCommand, MetadataListCommand, MetadataRemoveCommand, MetadataUpdateCommand, PageLocksCommand, ResetLostPartitions, SnapshotCommand, StateCommand, TracingConfigurationCommand, TxCommands, WalCommands

    public interface Command<T>

Abstract class for all control.sh commands, has already implemented methods and abstract methods. Define flow how to work with command.

### Method Summary

All Methods Static Methods Instance Methods Abstract Methods Default Methods
`T` `arg()`
`default String` `confirmationPrompt()`
`Object` `execute(GridClientConfiguration clientCfg, Logger logger)` Actual command execution.
`default boolean` `experimental()` Return `true` if the command is experimental or `false` otherwise.
`default boolean` `experimentalEnabled()`
`static String` `extendToLen(String s, int targetLen)` Appends spaces to end of input string for extending to needed length.
`String` `name()`
`default void` `parseArguments(CommandArgIterator argIterator)` Parse command-specific arguments.
`default void` `prepareConfirmation(GridClientConfiguration clientCfg)` Prepares confirmation for the command.
`void` `printUsage(Logger logger)` Print info for user about command (parameters, use cases and so on).
`static GridClient` `startClient(GridClientConfiguration clientCfg)` Method to create thin client for communication with cluster.
`static void` `usage(Logger logger, String desc, CommandList cmd, @Nullable Map<String,String> paramsDesc, String... args)` Print command usage.
`static void` `usage(Logger logger, String desc, CommandList cmd, String... args)` Print command usage.
`static void` `usageParams(Map<String,String> paramsDesc, String indent, Logger logger)` Print cache command arguments usage.

### Method Detail

#### startClient

    static GridClient startClient(GridClientConfiguration clientCfg)
                           throws Exception

Method to create thin client for communication with cluster.

Parameters:
  `clientCfg` - Thin client configuration.
Returns:
  Grid thin client instance which is already connected to cluster.
Throws:
  `Exception` - If error occur.

#### usage

    static void usage(Logger logger,
                      String desc,
                      CommandList cmd,
                      String... args)

Print command usage.

Parameters:
  `logger` - Logger to use.
  `desc` - Command description.
  `cmd` - Command.
  `args` - Arguments.

#### usage

    static void usage(Logger logger,
                      String desc,
                      CommandList cmd,
                      @Nullable
                      @Nullable Map<String,String> paramsDesc,
                      String... args)

Print command usage.

Parameters:
  `logger` - Logger to use.
  `desc` - Command description.
  `cmd` - Command.
  `paramsDesc` - Description of parameters (optional).
  `args` - Arguments.

#### usageParams

    static void usageParams(Map<String,String> paramsDesc,
                            String indent,
                            Logger logger)

Print cache command arguments usage.

Parameters:
  `paramsDesc` - Cache command arguments description.
  `indent` - Indent string.
  `logger` - Logger to use.

#### extendToLen

    static String extendToLen(String s,
                              int targetLen)

Appends spaces to end of input string for extending to needed length.

Parameters:
  `s` - Input string.
  `targetLen` - Needed length.
Returns:
  String with appended spaces on the end.

#### execute

    Object execute(GridClientConfiguration clientCfg,
                   Logger logger)
            throws Exception

Actual command execution. Parameters for run should be already set by calling parseArguments method.

Parameters:
  `clientCfg` - Thin client configuration if connection to cluster is necessary.
  `logger` - Logger to use.
Returns:
  Result of operation (mostly usable for tests).
Throws:
  `Exception` - If error occur.

#### prepareConfirmation

    default void prepareConfirmation(GridClientConfiguration clientCfg)
                              throws Exception

Prepares confirmation for the command.

Parameters:
  `clientCfg` - Thin client configuration.
Throws:
  `Exception` - If error occur.

#### confirmationPrompt

    default String confirmationPrompt()

Returns:
  Message text to show user for. If null it means that confirmantion is not needed.

#### parseArguments

    default void parseArguments(CommandArgIterator argIterator)

Parse command-specific arguments.

Parameters:
  `argIterator` - Argument iterator.

#### arg

    T arg()

Returns:
  Command arguments which were parsed during `parseArguments(CommandArgIterator)` call.

#### printUsage

    void printUsage(Logger logger)

Print info for user about command (parameters, use cases and so on).

Parameters:
  `logger` - Logger to use.

#### name

    String name()

Returns:
  command name.

#### experimentalEnabled

    default boolean experimentalEnabled()

Returns:
  Value of `IgniteSystemProperties.IGNITE_ENABLE_EXPERIMENTAL_COMMAND`

#### experimental

    default boolean experimental()

Return `true` if the command is experimental or `false` otherwise.

Returns:
  `true` if the command is experimental or `false` otherwise.

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.9.0
Release Date | : October 15 2020