diff --git a/README.md b/README.md index 2994aca4..c563f833 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ It comes with the following main features: - Comes with integrations for all commonly used terminals for all operating systems - Exclusively uses established CLI tools and therefore works out of the box on most systems and doesn't require any additional setup - Allows you to customize the launched shell's init environment +- Launch connections from the GUI or commandline #### All your connections in one place @@ -43,7 +44,7 @@ It comes with the following main features: - Share connection configurations to any other trusted party through shareable URLs - Create desktop shortcuts to open your connections -drawing +drawing ## Data Explorer @@ -65,7 +66,7 @@ allows you to manage and work with all kinds of data sources: your favorite programming languages using the X-Pipe APIs - Connect select third party applications directly to X-Pipe through extensions -drawing +drawing ## Repository Structure diff --git a/app/build.gradle b/app/build.gradle index e6d64ce9..481661aa 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -136,7 +136,7 @@ run { systemProperty 'io.xpipe.app.writeSysOut', "true" systemProperty 'io.xpipe.app.developerMode', "true" systemProperty 'io.xpipe.app.logLevel', "trace" - systemProperty "io.xpipe.beacon.port", "21724" + // systemProperty "io.xpipe.beacon.port", "21724" // systemProperty "io.xpipe.beacon.printMessages", "true" systemProperty "io.xpipe.app.extensions", extensionDirList // systemProperty 'io.xpipe.app.debugPlatform', "true" diff --git a/app/src/main/java/io/xpipe/app/exchange/LaunchExchangeImpl.java b/app/src/main/java/io/xpipe/app/exchange/LaunchExchangeImpl.java new file mode 100644 index 00000000..46cdb031 --- /dev/null +++ b/app/src/main/java/io/xpipe/app/exchange/LaunchExchangeImpl.java @@ -0,0 +1,24 @@ +package io.xpipe.app.exchange; + +import io.xpipe.beacon.BeaconHandler; +import io.xpipe.beacon.exchange.LaunchExchange; +import io.xpipe.core.store.LaunchableStore; +import org.apache.commons.exec.CommandLine; + +import java.util.List; + +public class LaunchExchangeImpl extends LaunchExchange + implements MessageExchangeImpl { + + @Override + public Response handleRequest(BeaconHandler handler, Request msg) throws Exception { + var store = getStoreEntryByName(msg.getName(), false); + if (store.getStore() instanceof LaunchableStore s) { + var command = s.prepareLaunchCommand(); + var split = CommandLine.parse(command); + return Response.builder().command(List.of(split.toStrings())).build(); + } + + throw new IllegalArgumentException(); + } +} diff --git a/app/src/main/java/module-info.java b/app/src/main/java/module-info.java index 3abd3715..96830e7e 100644 --- a/app/src/main/java/module-info.java +++ b/app/src/main/java/module-info.java @@ -66,6 +66,7 @@ open module io.xpipe.app { requires com.jfoenix; requires org.kordamp.ikonli.javafx; requires org.kordamp.ikonli.material; + requires commons.exec; requires org.controlsfx.controls; requires io.sentry; requires io.xpipe.beacon; @@ -125,6 +126,7 @@ open module io.xpipe.app { StoreProviderListExchangeImpl, ListCollectionsExchangeImpl, OpenExchangeImpl, + LaunchExchangeImpl, FocusExchangeImpl, ListEntriesExchangeImpl, ProxyReadConnectionExchangeImpl, diff --git a/beacon/src/main/java/io/xpipe/beacon/exchange/LaunchExchange.java b/beacon/src/main/java/io/xpipe/beacon/exchange/LaunchExchange.java new file mode 100644 index 00000000..f0f65903 --- /dev/null +++ b/beacon/src/main/java/io/xpipe/beacon/exchange/LaunchExchange.java @@ -0,0 +1,33 @@ +package io.xpipe.beacon.exchange; + +import io.xpipe.beacon.RequestMessage; +import io.xpipe.beacon.ResponseMessage; +import lombok.Builder; +import lombok.NonNull; +import lombok.Value; +import lombok.extern.jackson.Jacksonized; + +import java.util.List; + +public class LaunchExchange implements MessageExchange { + + @Override + public String getId() { + return "launch"; + } + + @Jacksonized + @Builder + @Value + public static class Request implements RequestMessage { + @NonNull + String name; + } + + @Jacksonized + @Builder + @Value + public static class Response implements ResponseMessage { + @NonNull List command; + } +} diff --git a/beacon/src/main/java/module-info.java b/beacon/src/main/java/module-info.java index 32d780ba..fc090dc2 100644 --- a/beacon/src/main/java/module-info.java +++ b/beacon/src/main/java/module-info.java @@ -43,6 +43,7 @@ module io.xpipe.beacon { provides Module with BeaconJacksonModule; provides io.xpipe.beacon.exchange.MessageExchange with + LaunchExchange, ForwardExchange, InstanceExchange, EditStoreExchange, diff --git a/core/src/main/java/io/xpipe/core/store/CommandExecutionStore.java b/core/src/main/java/io/xpipe/core/store/CommandExecutionStore.java index 80303dd0..b5c8fce7 100644 --- a/core/src/main/java/io/xpipe/core/store/CommandExecutionStore.java +++ b/core/src/main/java/io/xpipe/core/store/CommandExecutionStore.java @@ -2,7 +2,12 @@ package io.xpipe.core.store; import io.xpipe.core.process.CommandProcessControl; -public interface CommandExecutionStore extends DataStore { +public interface CommandExecutionStore extends DataStore, LaunchableStore { + + @Override + default String prepareLaunchCommand() throws Exception { + return create().prepareTerminalOpen(); + } CommandProcessControl create() throws Exception; } diff --git a/core/src/main/java/io/xpipe/core/store/LaunchableStore.java b/core/src/main/java/io/xpipe/core/store/LaunchableStore.java new file mode 100644 index 00000000..1c03ee22 --- /dev/null +++ b/core/src/main/java/io/xpipe/core/store/LaunchableStore.java @@ -0,0 +1,6 @@ +package io.xpipe.core.store; + +public interface LaunchableStore extends DataStore { + + String prepareLaunchCommand() throws Exception; +} diff --git a/core/src/main/java/io/xpipe/core/store/ShellStore.java b/core/src/main/java/io/xpipe/core/store/ShellStore.java index a17086f7..764011a2 100644 --- a/core/src/main/java/io/xpipe/core/store/ShellStore.java +++ b/core/src/main/java/io/xpipe/core/store/ShellStore.java @@ -8,7 +8,7 @@ import io.xpipe.core.process.ShellType; import java.nio.charset.Charset; -public interface ShellStore extends DataStore, StatefulDataStore { +public interface ShellStore extends DataStore, StatefulDataStore, LaunchableStore { public static MachineStore local() { return new LocalStore(); @@ -24,6 +24,11 @@ public interface ShellStore extends DataStore, StatefulDataStore { return s instanceof LocalStore; } + @Override + default String prepareLaunchCommand() throws Exception { + return create().prepareTerminalOpen(); + } + default ShellProcessControl create() { var pc = createControl(); pc.onInit(processControl -> { diff --git a/gradle/gradle_scripts/commons.gradle b/gradle/gradle_scripts/commons.gradle index 3d2a4894..6269a728 100644 --- a/gradle/gradle_scripts/commons.gradle +++ b/gradle/gradle_scripts/commons.gradle @@ -6,6 +6,7 @@ dependencies { dep files("$buildDir/generated-modules/commons-lang3-3.12.0.jar") dep files("$buildDir/generated-modules/commons-io-2.11.0.jar") dep files("$buildDir/generated-modules/commons-math3-3.6.1.jar") + dep files("$buildDir/generated-modules/commons-exec-1.3.jar") } addDependenciesModuleInfo { @@ -40,6 +41,14 @@ addDependenciesModuleInfo { } ''' } + module { + artifact 'org.apache.commons:commons-exec:1.3' + moduleInfoSource = ''' + module commons.exec { + exports org.apache.commons.exec; + } + ''' + } module { artifact 'org.apache.commons:commons-collections4:4.4' moduleInfoSource = ''' diff --git a/version b/version index 8649ef1f..30954b8b 100644 --- a/version +++ b/version @@ -1 +1 @@ -0.4.27 \ No newline at end of file +0.4.28 \ No newline at end of file