-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Partial implementation updates
- Loading branch information
Showing
13 changed files
with
331 additions
and
160 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
...mon/src/main/java/com/fortify/cli/common/action/cli/cmd/AbstractActionNewHelpCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** | ||
* Copyright 2023 Open Text. | ||
* | ||
* The only warranties for products and services of Open Text | ||
* and its affiliates and licensors ("Open Text") are as may | ||
* be set forth in the express warranty statements accompanying | ||
* such products and services. Nothing herein should be construed | ||
* as constituting an additional warranty. Open Text shall not be | ||
* liable for technical or editorial errors or omissions contained | ||
* herein. The information contained herein is subject to change | ||
* without notice. | ||
*/ | ||
package com.fortify.cli.common.action.cli.cmd; | ||
|
||
import com.fortify.cli.common.action.cli.mixin.ActionResolverMixin; | ||
import com.fortify.cli.common.action.helper.ActionLoaderHelper.ActionValidationHandler; | ||
import com.fortify.cli.common.action.runner.n.ActionCommandLineFactory; | ||
import com.fortify.cli.common.action.runner.n.ActionRuntimeConfig; | ||
import com.fortify.cli.common.action.runner.n.ActionSourceConfig; | ||
import com.fortify.cli.common.cli.cmd.AbstractRunnableCommand; | ||
import com.fortify.cli.common.cli.mixin.CommandHelperMixin; | ||
|
||
import picocli.CommandLine; | ||
import picocli.CommandLine.Mixin; | ||
import picocli.CommandLine.Unmatched; | ||
|
||
public abstract class AbstractActionNewHelpCommand extends AbstractRunnableCommand { | ||
@Mixin private ActionResolverMixin.RequiredParameter actionResolver; | ||
@Mixin private CommandHelperMixin commandHelper; | ||
// We explicitly ignore any unknown CLI args, to allow for easy switching between run and help commands. | ||
@Unmatched private String[] actionArgs; | ||
|
||
@Override | ||
public Integer call() throws Exception { | ||
initMixins(); | ||
createCommandLine().usage(System.out); | ||
return 0; | ||
} | ||
|
||
private final CommandLine createCommandLine() { | ||
return ActionCommandLineFactory.builder() | ||
.actionSourceConfig(new ActionSourceConfig(actionResolver, actionResolver.loadAction(getType(), ActionValidationHandler.WARN))) | ||
.actionRuntimeConfig(createActionRuntimeConfig()) | ||
.build() | ||
.createCommandLine(); | ||
} | ||
|
||
protected abstract String getType(); | ||
protected abstract ActionRuntimeConfig createActionRuntimeConfig(); | ||
} |
50 changes: 50 additions & 0 deletions
50
...mmon/src/main/java/com/fortify/cli/common/action/cli/cmd/AbstractActionNewRunCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** | ||
* Copyright 2023 Open Text. | ||
* | ||
* The only warranties for products and services of Open Text | ||
* and its affiliates and licensors ("Open Text") are as may | ||
* be set forth in the express warranty statements accompanying | ||
* such products and services. Nothing herein should be construed | ||
* as constituting an additional warranty. Open Text shall not be | ||
* liable for technical or editorial errors or omissions contained | ||
* herein. The information contained herein is subject to change | ||
* without notice. | ||
*/ | ||
package com.fortify.cli.common.action.cli.cmd; | ||
|
||
import com.fortify.cli.common.action.cli.mixin.ActionResolverMixin; | ||
import com.fortify.cli.common.action.helper.ActionLoaderHelper.ActionValidationHandler; | ||
import com.fortify.cli.common.action.runner.n.ActionCommandLineFactory; | ||
import com.fortify.cli.common.action.runner.n.ActionRuntimeConfig; | ||
import com.fortify.cli.common.action.runner.n.ActionSourceConfig; | ||
import com.fortify.cli.common.cli.cmd.AbstractRunnableCommand; | ||
import com.fortify.cli.common.cli.mixin.CommandHelperMixin; | ||
|
||
import picocli.CommandLine; | ||
import picocli.CommandLine.Mixin; | ||
import picocli.CommandLine.Unmatched; | ||
|
||
public abstract class AbstractActionNewRunCommand extends AbstractRunnableCommand { | ||
@Mixin private ActionResolverMixin.RequiredParameter actionResolver; | ||
@Mixin private CommandHelperMixin commandHelper; | ||
@Unmatched private String[] actionArgs; | ||
|
||
@Override | ||
public Integer call() throws Exception { | ||
initMixins(); | ||
// TODO Handle progress writer, delayed console writers, ... | ||
createCommandLine().execute(actionArgs==null ? new String[] {} : actionArgs); | ||
return 0; | ||
} | ||
|
||
private final CommandLine createCommandLine() { | ||
return ActionCommandLineFactory.builder() | ||
.actionSourceConfig(new ActionSourceConfig(actionResolver, actionResolver.loadAction(getType(), ActionValidationHandler.WARN))) | ||
.actionRuntimeConfig(createActionRuntimeConfig()) | ||
.build() | ||
.createCommandLine(); | ||
} | ||
|
||
protected abstract String getType(); | ||
protected abstract ActionRuntimeConfig createActionRuntimeConfig(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.