1   /*
2    * SPDX-FileCopyrightText: none
3    * SPDX-License-Identifier: CC0-1.0
4    */
5   
6   package gov.nist.secauto.metaschema.cli.processor.command;
7   
8   import gov.nist.secauto.metaschema.cli.processor.CLIProcessor.CallingContext;
9   
10  import org.apache.commons.cli.CommandLine;
11  
12  import edu.umd.cs.findbugs.annotations.NonNull;
13  
14  public interface ICommandExecutor {
15    void execute() throws CommandExecutionException;
16  
17    @NonNull
18    static ICommandExecutor using(
19        @NonNull CallingContext callingContext,
20        @NonNull CommandLine commandLine,
21        @NonNull ExecutionFunction function) {
22      return () -> function.execute(callingContext, commandLine);
23    }
24  
25    @FunctionalInterface
26    interface ExecutionFunction {
27      void execute(
28          @NonNull CallingContext callingContext,
29          @NonNull CommandLine commandLine) throws CommandExecutionException;
30    }
31  }