Interface PosixCommands.CommandExecutor

Enclosing class:
PosixCommands

public static interface PosixCommands.CommandExecutor
Interface for executing shell commands in watch.

This interface allows the watch command to execute commands using different execution strategies. Implementations can provide shell integration, process execution, or other command execution mechanisms.

Example implementation for shell integration:

CommandExecutor executor = command -> {
    Object result = session.execute(String.join(" ", command));
    return result != null ? result.toString() : "";
};
  • Method Summary

    Modifier and Type
    Method
    Description
    execute(List<String> command)
    Execute a command and return its output.
  • Method Details

    • execute

      String execute(List<String> command) throws Exception
      Execute a command and return its output.

      The command is provided as a list of strings where the first element is the command name and subsequent elements are arguments.

      Parameters:
      command - the command to execute as a list of strings
      Returns:
      the command output as a string
      Throws:
      Exception - if execution fails