1
2
3
4
5
6 package gov.nist.secauto.metaschema.cli.processor.command;
7
8 import gov.nist.secauto.metaschema.cli.processor.CLIProcessor.CallingContext;
9 import gov.nist.secauto.metaschema.cli.processor.ExitStatus;
10 import gov.nist.secauto.metaschema.core.util.ObjectUtils;
11
12 import org.apache.commons.cli.CommandLine;
13
14 import edu.umd.cs.findbugs.annotations.NonNull;
15
16 public abstract class AbstractCommandExecutor implements ICommandExecutor {
17 @NonNull
18 private final CallingContext callingContext;
19 @NonNull
20 private final CommandLine commandLine;
21
22 public AbstractCommandExecutor(
23 @NonNull CallingContext callingContext,
24 @NonNull CommandLine commandLine) {
25 this.callingContext = callingContext;
26 this.commandLine = commandLine;
27 }
28
29 @NonNull
30 protected CallingContext getCallingContext() {
31 return callingContext;
32 }
33
34 @NonNull
35 protected CommandLine getCommandLine() {
36 return commandLine;
37 }
38
39 @Override
40 public abstract ExitStatus execute();
41
42 @NonNull
43 protected ICommand getCommand() {
44 return ObjectUtils.requireNonNull(getCallingContext().getTargetCommand());
45 }
46 }