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

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.lang.String execute​(java.util.List<java.lang.String> command)
      Execute a command and return its output.
    • Method Detail

      • execute

        java.lang.String execute​(java.util.List<java.lang.String> command)
                          throws java.lang.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:
        java.lang.Exception - if execution fails