Skip to content

Commit 1a3878e

Browse files
committed
resolve #249
1 parent e583ae0 commit 1a3878e

File tree

52 files changed

+248
-194
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+248
-194
lines changed

src/main/java/com/dtsx/astra/cli/AstraCli.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
import lombok.SneakyThrows;
4343
import lombok.experimental.Accessors;
4444
import lombok.val;
45-
import org.graalvm.collections.Pair;
45+
import org.apache.commons.lang3.tuple.Pair;
4646
import org.jetbrains.annotations.Nullable;
4747
import org.jetbrains.annotations.VisibleForTesting;
4848
import picocli.CommandLine;
@@ -229,20 +229,20 @@ public Pair<String, String> get(CliContext ctx) {
229229
val configFileExists = Files.exists(AstraConfig.resolveDefaultAstraConfigFile(ctx));
230230

231231
if (!configFileExists) {
232-
return Pair.create("Setup the Astra CLI", "${cli.name} setup");
232+
return Pair.of("Setup the Astra CLI", "${cli.name} setup");
233233
}
234234

235235
val autocompleteSetup = System.getenv(ConstEnvVars.COMPLETIONS_SETUP) != null;
236236

237237
if (!autocompleteSetup && ctx.isNotWindows()) {
238-
return Pair.create("Put this in your shell profile to generate completions and more!", "eval \"$(${cli.path} shellenv)\"");
238+
return Pair.of("Put this in your shell profile to generate completions and more!", "eval \"$(${cli.path} shellenv)\"");
239239
}
240240
} catch (Exception e) {
241241
ctx.log().exception("Error resolving main example for AstraCli", e);
242242
}
243243
}
244244

245-
return Pair.create("Create a new profile", "${cli.name} setup");
245+
return Pair.of("Create a new profile", "${cli.name} setup");
246246
}
247247
}
248248
}

src/main/java/com/dtsx/astra/cli/commands/AbstractConnectedCmd.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import com.dtsx.astra.cli.core.output.Hint;
1919
import com.dtsx.astra.sdk.utils.AstraEnvironment;
2020
import lombok.val;
21-
import org.graalvm.collections.Pair;
21+
import org.apache.commons.lang3.tuple.Pair;
2222
import org.jetbrains.annotations.Nullable;
2323
import picocli.CommandLine.ArgGroup;
2424
import picocli.CommandLine.Option;
@@ -101,7 +101,7 @@ public final Profile profile() {
101101
}
102102

103103
public final Pair<Profile, ProfileSource> profileAndSource() {
104-
return Pair.create(profile(), profileSource());
104+
return Pair.of(profile(), profileSource());
105105
}
106106

107107
private ProfileSource profileSource() {

src/main/java/com/dtsx/astra/cli/commands/NukeCmd.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ private OutputAll handleNuked(NukeResult res) {
9191
val summary = new StringBuilder();
9292
val nothingToReport = new ArrayList<String>();
9393

94-
appendToSummary("Files deleted", summary, nothingToReport, "deleted", res.deletedFiles().stream().collect(HashMap::new, (m, v) -> m.put(v, Optional.of(" @|faint (contained binary)|@").filter((_) -> res.cliBinaryPath().startsWith(v))), Map::putAll));
94+
appendToSummary("Files deleted", summary, nothingToReport, "deleted", res.deletedFiles().stream().collect(HashMap::new, (m, v) -> m.put(v, Optional.of(" @|faint (contained binary)|@").filter((_) -> res.cliPath().unwrap().startsWith(v))), Map::putAll));
9595
appendToSummary("Shell profiles containing @!astra!@", summary, nothingToReport, "needing updates", res.shellRcFilesToUpdate().stream().collect(HashMap::new, (m, v) -> m.put(v, Optional.empty()), Map::putAll));
9696
appendToSummary("Files skipped", summary, nothingToReport, "skipped", res.skipped().entrySet().stream().collect(HashMap::new, (m, v) -> m.put(v.getKey(), Optional.of(" - " + v.getValue().reason())), Map::putAll));
9797

@@ -134,7 +134,7 @@ private String buildCompleteUninstallationMsg(BinaryDeleteResult res) {
134134
case BinaryDeleted() -> """
135135
@|green Astra CLI binary has been successfully deleted from your system.|@
136136
""";
137-
case BinaryMustBeDeleted(var deleteCommand) -> """
137+
case CLIMustBeDeleted(var deleteCommand) -> """
138138
To complete the uninstallation, please run the following command in your terminal:
139139
140140
%s

src/main/java/com/dtsx/astra/cli/commands/ShellEnvCmd.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.dtsx.astra.cli.core.exceptions.AstraCliException;
44
import com.dtsx.astra.cli.core.help.Example;
55
import com.dtsx.astra.cli.core.mixins.HelpMixin;
6+
import com.dtsx.astra.cli.core.properties.CliProperties.AstraBinary;
67
import com.dtsx.astra.cli.core.properties.CliProperties.ConstEnvVars;
78
import com.dtsx.astra.cli.utils.FileUtils;
89
import lombok.val;
@@ -86,18 +87,18 @@ public class ShellEnvCmd implements Runnable {
8687

8788
@Override
8889
public void run() {
89-
val binaryPath = FileUtils.getCurrentBinaryPath();
90+
val binaryPath = FileUtils.resolvePathToAstra();
9091

91-
if (binaryPath.isEmpty()) {
92+
if (!(binaryPath instanceof AstraBinary)) {
9293
throw new AstraCliException(UNSUPPORTED_EXECUTION, """
9394
@|bold,red Error: Can not run this command when not executing from a binary|@
9495
""");
9596
}
9697

9798
val sb = new StringBuilder();
9899

99-
sb.append("export PATH=").append(binaryPath.get().getParent()).append(":$PATH").append(NL);
100-
sb.append("source <(").append(binaryPath.get()).append(" compgen)").append(NL);
100+
sb.append("export PATH=").append(binaryPath.unwrap().getParent()).append(":$PATH").append(NL);
101+
sb.append("source <(").append(binaryPath.unwrap()).append(" compgen)").append(NL);
101102

102103
if ($ignoreMultiplePaths) {
103104
sb.append("export ").append(ConstEnvVars.IGNORE_MULTIPLE_PATHS).append("=true").append(NL);

src/main/java/com/dtsx/astra/cli/commands/streaming/StreamingCreateCmd.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import com.dtsx.astra.cli.operations.Operation;
1515
import com.dtsx.astra.cli.operations.streaming.StreamingCreateOperation;
1616
import lombok.val;
17-
import org.graalvm.collections.Pair;
17+
import org.apache.commons.lang3.tuple.Pair;
1818
import org.jetbrains.annotations.Nullable;
1919
import picocli.CommandLine.ArgGroup;
2020
import picocli.CommandLine.Command;
@@ -114,7 +114,7 @@ protected Operation<StreamingCreateResult> mkOperation() {
114114
return new StreamingCreateOperation(streamingGateway, new StreamingCreateRequest(
115115
$tenantName,
116116
($tenantCreationOptions.$clusterOrCloud.$regionSpec != null)
117-
? Either.pure(Pair.create($tenantCreationOptions.$clusterOrCloud.$regionSpec.$cloud, $tenantCreationOptions.$clusterOrCloud.$regionSpec.$region))
117+
? Either.pure(Pair.of($tenantCreationOptions.$clusterOrCloud.$regionSpec.$cloud, $tenantCreationOptions.$clusterOrCloud.$regionSpec.$region))
118118
: Either.left($tenantCreationOptions.$clusterOrCloud.$cluster.orElseThrow()),
119119
$tenantCreationOptions.$plan,
120120
$tenantCreationOptions.$userEmail,

src/main/java/com/dtsx/astra/cli/core/completions/ProfileLinkedCompletionsCache.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import com.dtsx.astra.cli.core.config.Profile;
77
import com.dtsx.astra.cli.core.config.ProfileName;
88
import lombok.val;
9-
import org.graalvm.collections.Pair;
9+
import org.apache.commons.lang3.tuple.Pair;
1010
import org.jetbrains.annotations.VisibleForTesting;
1111

1212
import java.nio.file.Path;

src/main/java/com/dtsx/astra/cli/core/completions/caches/DbCompletionsCache.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import com.dtsx.astra.cli.core.CliContext;
55
import com.dtsx.astra.cli.core.completions.ProfileLinkedCompletionsCache;
66
import com.dtsx.astra.cli.core.config.Profile;
7-
import org.graalvm.collections.Pair;
7+
import org.apache.commons.lang3.tuple.Pair;
88

99
public class DbCompletionsCache extends ProfileLinkedCompletionsCache {
1010
public DbCompletionsCache(CliContext ctx,Pair<Profile, ProfileSource> profileAndSource) {

src/main/java/com/dtsx/astra/cli/core/completions/caches/PcuGroupsCompletionsCache.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import com.dtsx.astra.cli.core.CliContext;
55
import com.dtsx.astra.cli.core.completions.ProfileLinkedCompletionsCache;
66
import com.dtsx.astra.cli.core.config.Profile;
7-
import org.graalvm.collections.Pair;
7+
import org.apache.commons.lang3.tuple.Pair;
88

99
public class PcuGroupsCompletionsCache extends ProfileLinkedCompletionsCache {
1010
public PcuGroupsCompletionsCache(CliContext ctx,Pair<Profile, ProfileSource> profileAndSource) {

src/main/java/com/dtsx/astra/cli/core/completions/caches/TenantCompletionsCache.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import com.dtsx.astra.cli.core.CliContext;
55
import com.dtsx.astra.cli.core.completions.ProfileLinkedCompletionsCache;
66
import com.dtsx.astra.cli.core.config.Profile;
7-
import org.graalvm.collections.Pair;
7+
import org.apache.commons.lang3.tuple.Pair;
88

99
public class TenantCompletionsCache extends ProfileLinkedCompletionsCache {
1010
public TenantCompletionsCache(CliContext ctx,Pair<Profile, ProfileSource> profileAndSource) {

src/main/java/com/dtsx/astra/cli/core/completions/caches/UserCompletionsCache.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import com.dtsx.astra.cli.core.CliContext;
55
import com.dtsx.astra.cli.core.completions.ProfileLinkedCompletionsCache;
66
import com.dtsx.astra.cli.core.config.Profile;
7-
import org.graalvm.collections.Pair;
7+
import org.apache.commons.lang3.tuple.Pair;
88

99
public class UserCompletionsCache extends ProfileLinkedCompletionsCache {
1010
public UserCompletionsCache(CliContext ctx,Pair<Profile, ProfileSource> profileAndSource) {

0 commit comments

Comments
 (0)