-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Refactor wait-for commands (closes #350)
- Loading branch information
Showing
26 changed files
with
275 additions
and
225 deletions.
There are no files selected for viewing
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
36 changes: 0 additions & 36 deletions
36
...cli-common/src/main/java/com/fortify/cli/common/rest/cli/mixin/WaitHelperWaitOptions.java
This file was deleted.
Oops, something went wrong.
66 changes: 66 additions & 0 deletions
66
...i-common/src/main/java/com/fortify/cli/common/rest/cli/mixin/WaitHelperWaitTypeMixin.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,66 @@ | ||
/******************************************************************************* | ||
* 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.rest.cli.mixin; | ||
|
||
import java.util.ArrayList; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
|
||
import com.fortify.cli.common.rest.cli.mixin.WaitHelperWaitTypeMixin.AnyOrAllTypeConverter.AnyOrAllIterable; | ||
import com.fortify.cli.common.rest.wait.WaitType; | ||
import com.fortify.cli.common.rest.wait.WaitType.AnyOrAll; | ||
import com.fortify.cli.common.rest.wait.WaitType.LoopType; | ||
|
||
import lombok.Getter; | ||
import picocli.CommandLine.ArgGroup; | ||
import picocli.CommandLine.ITypeConverter; | ||
import picocli.CommandLine.Option; | ||
|
||
public final class WaitHelperWaitTypeMixin { | ||
@Getter @ArgGroup(exclusive = true, multiplicity = "0..1") | ||
private WaitHelperWaitTypeArgGroup waitTypeArgGroup; | ||
|
||
public final WaitType getWaitType() { | ||
if ( waitTypeArgGroup==null ) { | ||
return new WaitType(LoopType.Until, AnyOrAll.all_match); | ||
} else if ( waitTypeArgGroup.untilAnyOrAll!=null ) { | ||
return new WaitType(LoopType.Until, waitTypeArgGroup.untilAnyOrAll); | ||
} else { | ||
return new WaitType(LoopType.While, waitTypeArgGroup.whileAnyOrAll); | ||
} | ||
} | ||
|
||
private static final class WaitHelperWaitTypeArgGroup { | ||
@Option(names = {"--until", "-u"}, required = true, paramLabel="any-match|all-match", converter = AnyOrAllTypeConverter.class, completionCandidates = AnyOrAllIterable.class) | ||
@Getter private AnyOrAll untilAnyOrAll; | ||
@Option(names = {"--while", "-w"}, required = true, paramLabel="any-match|all-match", converter = AnyOrAllTypeConverter.class, completionCandidates = AnyOrAllIterable.class) | ||
@Getter private AnyOrAll whileAnyOrAll; | ||
} | ||
|
||
public static final class AnyOrAllTypeConverter implements ITypeConverter<AnyOrAll> { | ||
@Override | ||
public AnyOrAll convert(String value) throws Exception { | ||
return AnyOrAll.valueOf(value.replace('-', '_')); | ||
} | ||
|
||
public static final class AnyOrAllIterable extends ArrayList<String> { | ||
private static final long serialVersionUID = 1L; | ||
public AnyOrAllIterable() { | ||
super(Stream.of(AnyOrAll.values()) | ||
.map(Enum::name) | ||
.map(s->s.replace('_', '-')) | ||
.collect(Collectors.toList())); | ||
} | ||
} | ||
} | ||
} |
20 changes: 0 additions & 20 deletions
20
...fcli-common/src/main/java/com/fortify/cli/common/rest/wait/IWaitHelperWaitDefinition.java
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
...mon/src/main/java/com/fortify/cli/common/rest/wait/IWaitHelperWaitDefinitionSupplier.java
This file was deleted.
Oops, something went wrong.
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.