001/* 002 * SPDX-FileCopyrightText: none 003 * SPDX-License-Identifier: CC0-1.0 004 */ 005 006package gov.nist.secauto.metaschema.cli.processor.command; 007 008import gov.nist.secauto.metaschema.cli.processor.CLIProcessor.CallingContext; 009import gov.nist.secauto.metaschema.cli.processor.ExitStatus; 010 011import org.apache.commons.cli.CommandLine; 012 013import edu.umd.cs.findbugs.annotations.NonNull; 014 015public interface ICommandExecutor { 016 @NonNull 017 ExitStatus execute(); 018 019 @NonNull 020 static ICommandExecutor using( 021 @NonNull CallingContext callingContext, 022 @NonNull CommandLine commandLine, 023 @NonNull ExecutionFunction function) { 024 return new ICommandExecutor() { 025 @Override 026 public ExitStatus execute() { 027 return function.execute(callingContext, commandLine); 028 } 029 030 }; 031 } 032 033 @FunctionalInterface 034 interface ExecutionFunction { 035 @NonNull 036 ExitStatus execute( 037 @NonNull CallingContext callingContext, 038 @NonNull CommandLine commandLine); 039 } 040}