Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/fortify/fcli into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
psmf22 committed Jul 28, 2023
2 parents fe8c9aa + 73c58ae commit 5a819e4
Show file tree
Hide file tree
Showing 199 changed files with 810 additions and 777 deletions.
4 changes: 2 additions & 2 deletions fcli-core/fcli-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ apply plugin: 'com.github.johnrengelman.shadow'
dependencies {
implementation project("${fcliCommonRef}")
implementation project("${fcliConfigRef}")
implementation project("${fcliStateRef}")
implementation project("${fcliFoDRef}")
implementation project("${fcliSSCRef}")
implementation project("${fcliFoDRef}")
implementation project("${fcliSCSastRef}")
implementation project("${fcliSCDastRef}")
implementation project("${fcliToolRef}")
implementation project("${fcliLicenseRef}")
implementation project("${fcliUtilRef}")

// Logging dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
package com.fortify.cli.app._main.cli.cmd;

import com.fortify.cli.app.FortifyCLIVersionProvider;
import com.fortify.cli.common.cli.cmd.AbstractFortifyCLICommand;
import com.fortify.cli.common.cli.cmd.AbstractContainerCommand;
import com.fortify.cli.common.util.DisableTest;
import com.fortify.cli.common.util.DisableTest.TestType;
import com.fortify.cli.config._main.cli.cmd.ConfigCommands;
import com.fortify.cli.fod._main.cli.cmd.FoDCommands;
import com.fortify.cli.license._main.cli.cmd.LicenseCommands;
import com.fortify.cli.sc_dast._main.cli.cmd.SCDastCommands;
import com.fortify.cli.sc_sast._main.cli.cmd.SCSastCommands;
import com.fortify.cli.ssc._main.cli.cmd.SSCCommands;
import com.fortify.cli.state._main.cli.cmd.StateCommands;
import com.fortify.cli.tool._main.cli.cmd.ToolCommands;
import com.fortify.cli.util._main.cli.cmd.UtilCommands;

Expand All @@ -44,16 +44,16 @@
versionProvider = FortifyCLIVersionProvider.class,
subcommands = {
ConfigCommands.class,
StateCommands.class,
FoDCommands.class,
SCDastCommands.class,
SCSastCommands.class,
SSCCommands.class,
ToolCommands.class,
LicenseCommands.class,
UtilCommands.class
}
)
public class FCLIRootCommands extends AbstractFortifyCLICommand {
public class FCLIRootCommands extends AbstractContainerCommand {
// We only want to have the --version option on the top-level fcli command,
@Option(names = {"-V", "--version"}, versionHelp = true, scope = ScopeType.LOCAL, order = -1002)
@DisableTest(TestType.OPT_SHORT_NAME)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

import org.slf4j.LoggerFactory;

import com.fortify.cli.common.cli.cmd.AbstractFortifyCLICommand;
import com.fortify.cli.common.cli.cmd.AbstractFortifyCLICommand.GenericOptionsArgGroup;
import com.fortify.cli.common.cli.cmd.AbstractFortifyCLICommand.LogLevel;
import com.fortify.cli.common.cli.cmd.AbstractRunnableCommand;
import com.fortify.cli.common.cli.cmd.AbstractRunnableCommand.GenericOptionsArgGroup;
import com.fortify.cli.common.cli.cmd.AbstractRunnableCommand.LogLevel;

import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext;
Expand Down Expand Up @@ -111,7 +111,7 @@ private CommandLine createGenericOptionsCommandLine() {

@Command(name = "fcli")
@RequiredArgsConstructor
public static final class FortifyCLIInitializerCommand extends AbstractFortifyCLICommand implements Runnable {
public static final class FortifyCLIInitializerCommand extends AbstractRunnableCommand implements Runnable {
private final Consumer<GenericOptionsArgGroup> consumer;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ private void checkOptions(Results results, CommandSpec cmdSpec) {

private void checkStandardOptions(Results results, CommandSpec spec) {
var optionNames = spec.optionsMap().keySet();
var expectedOptionNames = Arrays.asList("-h", "--help", "--log-level", "--log-file", "--env-prefix");
var expectedOptionNames = spec.userObject() instanceof Runnable
? Arrays.asList("-h", "--help", "--log-level", "--log-file", "--env-prefix")
: Arrays.asList("-h", "--help");
if ( !optionNames.containsAll(expectedOptionNames) ) {
results.add(TestType.CMD_STD_OPTS, Level.ERROR, spec, "Missing one or more standard option names: "+expectedOptionNames);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*******************************************************************************
* Copyright 2021, 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.cli.cmd;

import picocli.CommandLine.Option;

/**
* This abstract class should be used as the base class for all fcli container commands.
* It is responsible for providing the standard help option.
*
* @author Ruud Senden
*/
public abstract class AbstractContainerCommand {
@Option(names = {"-h", "--help"}, usageHelp = true)
private boolean usageHelpRequested;
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import picocli.CommandLine.Spec;

/**
* This abstract class should be used as the base class for all fcli commands.
* This abstract class should be used as the base class for all runnable fcli commands.
* It is responsible for providing the following fcli features:
* <ul>
* <li>Providing standard command configuration settings (default value provider, ...)</li>
Expand All @@ -36,7 +36,7 @@
*
* @author Ruud Senden
*/
public class AbstractFortifyCLICommand {
public abstract class AbstractRunnableCommand implements Runnable {
// Have picocli inject the CommandSpec representing the current command
@Spec private CommandSpec commandSpec;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*******************************************************************************/
package com.fortify.cli.common.cli.mixin;

import com.fortify.cli.common.cli.cmd.AbstractFortifyCLICommand;
import com.fortify.cli.common.cli.cmd.AbstractRunnableCommand;

import picocli.CommandLine.Model.CommandSpec;
import picocli.CommandLine.Spec;
Expand All @@ -28,7 +28,7 @@
* <p>Mixins usually wouldn't implement this interface directly, but instead
* utilize {@link CommandHelperMixin} as it provides some useful utility methods
* related to the the injected {@link CommandSpec}. Injection is handled
* by {@link AbstractFortifyCLICommand}.</p>
* by {@link AbstractRunnableCommand}.</p>
*
* @author rsenden
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
import java.util.Arrays;
import java.util.List;

import com.fortify.cli.common.cli.cmd.AbstractFortifyCLICommand;
import com.fortify.cli.common.cli.cmd.AbstractRunnableCommand;
import com.fortify.cli.common.output.cli.mixin.IOutputHelper;
import com.fortify.cli.common.output.writer.ISingularSupplier;

public abstract class AbstractOutputCommand extends AbstractFortifyCLICommand implements Runnable, ISingularSupplier {
public abstract class AbstractOutputCommand extends AbstractRunnableCommand implements Runnable, ISingularSupplier {
private static final List<Class<?>> supportedInterfaces = Arrays.asList(
IBaseRequestSupplier.class,
IJsonNodeSupplier.class);
Expand Down
Loading

0 comments on commit 5a819e4

Please sign in to comment.