mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-09-30 00:56:56 +13:00
Store children rework and script fixes
This commit is contained in:
parent
09052de9ee
commit
0d065dc14e
22 changed files with 101 additions and 83 deletions
|
@ -1,9 +1,7 @@
|
||||||
package io.xpipe.app.comp;
|
package io.xpipe.app.comp;
|
||||||
|
|
||||||
import io.xpipe.app.comp.base.BackgroundImageComp;
|
|
||||||
import io.xpipe.app.comp.base.SideMenuBarComp;
|
import io.xpipe.app.comp.base.SideMenuBarComp;
|
||||||
import io.xpipe.app.core.AppFont;
|
import io.xpipe.app.core.AppFont;
|
||||||
import io.xpipe.app.core.AppImages;
|
|
||||||
import io.xpipe.app.core.AppLayoutModel;
|
import io.xpipe.app.core.AppLayoutModel;
|
||||||
import io.xpipe.app.fxcomps.Comp;
|
import io.xpipe.app.fxcomps.Comp;
|
||||||
import io.xpipe.app.fxcomps.CompStructure;
|
import io.xpipe.app.fxcomps.CompStructure;
|
||||||
|
@ -11,18 +9,18 @@ import io.xpipe.app.fxcomps.SimpleCompStructure;
|
||||||
import io.xpipe.app.fxcomps.util.PlatformThread;
|
import io.xpipe.app.fxcomps.util.PlatformThread;
|
||||||
import io.xpipe.app.prefs.AppPrefs;
|
import io.xpipe.app.prefs.AppPrefs;
|
||||||
import javafx.scene.layout.BorderPane;
|
import javafx.scene.layout.BorderPane;
|
||||||
|
import javafx.scene.layout.Pane;
|
||||||
import javafx.scene.layout.Region;
|
import javafx.scene.layout.Region;
|
||||||
import javafx.scene.layout.StackPane;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class AppLayoutComp extends Comp<CompStructure<StackPane>> {
|
public class AppLayoutComp extends Comp<CompStructure<Pane>> {
|
||||||
|
|
||||||
private final AppLayoutModel model = AppLayoutModel.get();
|
private final AppLayoutModel model = AppLayoutModel.get();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompStructure<StackPane> createBase() {
|
public CompStructure<Pane> createBase() {
|
||||||
var map = new HashMap<AppLayoutModel.Entry, Region>();
|
var map = new HashMap<AppLayoutModel.Entry, Region>();
|
||||||
getRegion(model.getEntries().get(0), map);
|
getRegion(model.getEntries().get(0), map);
|
||||||
getRegion(model.getEntries().get(1), map);
|
getRegion(model.getEntries().get(1), map);
|
||||||
|
@ -31,6 +29,7 @@ public class AppLayoutComp extends Comp<CompStructure<StackPane>> {
|
||||||
var sidebar = new SideMenuBarComp(model.getSelected(), model.getEntries());
|
var sidebar = new SideMenuBarComp(model.getSelected(), model.getEntries());
|
||||||
pane.setCenter(getRegion(model.getSelected().getValue(), map));
|
pane.setCenter(getRegion(model.getSelected().getValue(), map));
|
||||||
pane.setRight(sidebar.createRegion());
|
pane.setRight(sidebar.createRegion());
|
||||||
|
pane.getStyleClass().add("background");
|
||||||
model.getSelected().addListener((c, o, n) -> {
|
model.getSelected().addListener((c, o, n) -> {
|
||||||
if (o != null && o.equals(model.getEntries().get(2))) {
|
if (o != null && o.equals(model.getEntries().get(2))) {
|
||||||
AppPrefs.get().save();
|
AppPrefs.get().save();
|
||||||
|
@ -41,12 +40,7 @@ public class AppLayoutComp extends Comp<CompStructure<StackPane>> {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
AppFont.normal(pane);
|
AppFont.normal(pane);
|
||||||
|
return new SimpleCompStructure<>(pane);
|
||||||
var bg = new BackgroundImageComp(AppImages.image("bg.png"))
|
|
||||||
.styleClass("background")
|
|
||||||
.hide(AppPrefs.get().performanceMode());
|
|
||||||
|
|
||||||
return new SimpleCompStructure<>(new StackPane(bg.createRegion(), pane));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Region getRegion(AppLayoutModel.Entry entry, Map<AppLayoutModel.Entry, Region> map) {
|
private Region getRegion(AppLayoutModel.Entry entry, Map<AppLayoutModel.Entry, Region> map) {
|
||||||
|
|
|
@ -20,7 +20,7 @@ import javafx.scene.input.KeyCombination;
|
||||||
import javafx.scene.layout.*;
|
import javafx.scene.layout.*;
|
||||||
import org.kordamp.ikonli.javafx.FontIcon;
|
import org.kordamp.ikonli.javafx.FontIcon;
|
||||||
|
|
||||||
public class StoreEntryListSideComp extends SimpleComp {
|
public class StoreEntryListStatusComp extends SimpleComp {
|
||||||
|
|
||||||
private Region createGroupListHeader() {
|
private Region createGroupListHeader() {
|
||||||
var label = new Label();
|
var label = new Label();
|
|
@ -4,9 +4,7 @@ import io.xpipe.app.fxcomps.Comp;
|
||||||
import io.xpipe.app.fxcomps.SimpleComp;
|
import io.xpipe.app.fxcomps.SimpleComp;
|
||||||
import io.xpipe.app.fxcomps.impl.StoreCategoryListComp;
|
import io.xpipe.app.fxcomps.impl.StoreCategoryListComp;
|
||||||
import io.xpipe.app.fxcomps.impl.VerticalComp;
|
import io.xpipe.app.fxcomps.impl.VerticalComp;
|
||||||
import javafx.scene.layout.Priority;
|
|
||||||
import javafx.scene.layout.Region;
|
import javafx.scene.layout.Region;
|
||||||
import javafx.scene.layout.VBox;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -15,12 +13,12 @@ public class StoreSidebarComp extends SimpleComp {
|
||||||
@Override
|
@Override
|
||||||
protected Region createSimple() {
|
protected Region createSimple() {
|
||||||
var sideBar = new VerticalComp(List.of(
|
var sideBar = new VerticalComp(List.of(
|
||||||
new StoreEntryListSideComp(),
|
new StoreEntryListStatusComp(),
|
||||||
new StoreSortComp(),
|
new StoreSortComp(),
|
||||||
new StoreCategoryListComp(),
|
new StoreCategoryListComp(StoreViewState.get().getAllConnectionsCategory()),
|
||||||
Comp.of(() -> new Region()).styleClass("bar").styleClass("filler-bar")));
|
new StoreCategoryListComp(StoreViewState.get().getAllScriptsCategory()),
|
||||||
|
Comp.of(() -> new Region()).styleClass("bar").styleClass("filler-bar").vgrow()));
|
||||||
sideBar.apply(struc -> struc.get().setFillWidth(true));
|
sideBar.apply(struc -> struc.get().setFillWidth(true));
|
||||||
sideBar.apply(s -> VBox.setVgrow(s.get().getChildren().get(2), Priority.ALWAYS));
|
|
||||||
sideBar.styleClass("sidebar");
|
sideBar.styleClass("sidebar");
|
||||||
sideBar.prefWidth(240);
|
sideBar.prefWidth(240);
|
||||||
return sideBar.createRegion();
|
return sideBar.createRegion();
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class StoreCategoryComp extends SimpleComp {
|
||||||
var name = new LazyTextFieldComp(category.nameProperty())
|
var name = new LazyTextFieldComp(category.nameProperty())
|
||||||
.apply(struc -> {
|
.apply(struc -> {
|
||||||
struc.get().prefWidthProperty().unbind();
|
struc.get().prefWidthProperty().unbind();
|
||||||
struc.get().setPrefWidth(100);
|
struc.get().setPrefWidth(150);
|
||||||
struc.getTextField().minWidthProperty().bind(struc.get().widthProperty());
|
struc.getTextField().minWidthProperty().bind(struc.get().widthProperty());
|
||||||
})
|
})
|
||||||
.styleClass("name")
|
.styleClass("name")
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package io.xpipe.app.fxcomps.impl;
|
package io.xpipe.app.fxcomps.impl;
|
||||||
|
|
||||||
import io.xpipe.app.comp.storage.store.StoreViewState;
|
import io.xpipe.app.comp.storage.store.StoreCategoryWrapper;
|
||||||
import io.xpipe.app.fxcomps.Comp;
|
|
||||||
import io.xpipe.app.fxcomps.SimpleComp;
|
import io.xpipe.app.fxcomps.SimpleComp;
|
||||||
import javafx.scene.layout.Region;
|
import javafx.scene.layout.Region;
|
||||||
|
|
||||||
|
@ -9,14 +8,16 @@ import java.util.List;
|
||||||
|
|
||||||
public class StoreCategoryListComp extends SimpleComp {
|
public class StoreCategoryListComp extends SimpleComp {
|
||||||
|
|
||||||
|
private final StoreCategoryWrapper root;
|
||||||
|
|
||||||
|
public StoreCategoryListComp(StoreCategoryWrapper root) {
|
||||||
|
this.root = root;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Region createSimple() {
|
protected Region createSimple() {
|
||||||
var all = StoreViewState.get().getAllConnectionsCategory();
|
|
||||||
var scripts = StoreViewState.get().getAllScriptsCategory();
|
|
||||||
return new VerticalComp(List.of(
|
return new VerticalComp(List.of(
|
||||||
new StoreCategoryComp(all),
|
new StoreCategoryComp(root)))
|
||||||
Comp.vspacer(10),
|
|
||||||
new StoreCategoryComp(scripts)))
|
|
||||||
.apply(struc -> struc.get().setFillWidth(true))
|
.apply(struc -> struc.get().setFillWidth(true))
|
||||||
.apply(struc -> struc.get().setSpacing(3))
|
.apply(struc -> struc.get().setSpacing(3))
|
||||||
.styleClass("store-category-bar")
|
.styleClass("store-category-bar")
|
||||||
|
|
|
@ -115,7 +115,7 @@ public abstract class DataStorage {
|
||||||
}
|
}
|
||||||
|
|
||||||
e.setInRefresh(true);
|
e.setInRefresh(true);
|
||||||
Map<String, FixedChildStore> newChildren;
|
List<? extends DataStoreEntryRef<? extends FixedChildStore>> newChildren;
|
||||||
try {
|
try {
|
||||||
newChildren = ((FixedHierarchyStore) (e.getStore())).listChildren(e);
|
newChildren = ((FixedHierarchyStore) (e.getStore())).listChildren(e);
|
||||||
e.setInRefresh(false);
|
e.setInRefresh(false);
|
||||||
|
@ -127,19 +127,19 @@ public abstract class DataStorage {
|
||||||
|
|
||||||
var oldChildren = getStoreEntries().stream().filter(other -> e.equals(other.getProvider().getLogicalParent(other))).toList();
|
var oldChildren = getStoreEntries().stream().filter(other -> e.equals(other.getProvider().getLogicalParent(other))).toList();
|
||||||
var toRemove = oldChildren.stream()
|
var toRemove = oldChildren.stream()
|
||||||
.filter(entry -> newChildren.entrySet().stream()
|
.filter(entry -> newChildren.stream()
|
||||||
.noneMatch(
|
.noneMatch(
|
||||||
nc -> nc.getValue().getFixedId() == ((FixedChildStore) entry.getStore()).getFixedId()))
|
nc -> nc.getStore().getFixedId() == ((FixedChildStore) entry.getStore()).getFixedId()))
|
||||||
.toList();
|
.toList();
|
||||||
var toAdd = newChildren.entrySet().stream()
|
var toAdd = newChildren.stream()
|
||||||
.filter(entry -> oldChildren.stream()
|
.filter(entry -> oldChildren.stream()
|
||||||
.noneMatch(oc -> ((FixedChildStore) oc.getStore()).getFixedId()
|
.noneMatch(oc -> ((FixedChildStore) oc.getStore()).getFixedId()
|
||||||
== entry.getValue().getFixedId()))
|
== entry.getStore().getFixedId()))
|
||||||
.toList();
|
.toList();
|
||||||
var toUpdate = oldChildren.stream()
|
var toUpdate = oldChildren.stream()
|
||||||
.map(entry -> {
|
.map(entry -> {
|
||||||
FixedChildStore found = newChildren.values().stream()
|
var found = newChildren.stream()
|
||||||
.filter(nc -> nc.getFixedId() == ((FixedChildStore) entry.getStore()).getFixedId())
|
.filter(nc -> nc.getStore().getFixedId() == ((FixedChildStore) entry.getStore()).getFixedId())
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
return new Pair<>(entry, found);
|
return new Pair<>(entry, found);
|
||||||
|
@ -153,18 +153,14 @@ public abstract class DataStorage {
|
||||||
|
|
||||||
deleteWithChildren(toRemove.toArray(DataStoreEntry[]::new));
|
deleteWithChildren(toRemove.toArray(DataStoreEntry[]::new));
|
||||||
addStoreEntriesIfNotPresent(toAdd.stream()
|
addStoreEntriesIfNotPresent(toAdd.stream()
|
||||||
.map(stringDataStoreEntry -> DataStoreEntry.createNew(
|
.map(DataStoreEntryRef::get)
|
||||||
UUID.randomUUID(),
|
|
||||||
e.getCategoryUuid(),
|
|
||||||
stringDataStoreEntry.getKey(),
|
|
||||||
stringDataStoreEntry.getValue()))
|
|
||||||
.toArray(DataStoreEntry[]::new));
|
.toArray(DataStoreEntry[]::new));
|
||||||
toUpdate.forEach(entry -> {
|
toUpdate.forEach(pair -> {
|
||||||
propagateUpdate(
|
propagateUpdate(
|
||||||
() -> {
|
() -> {
|
||||||
entry.getKey().setStoreInternal(entry.getValue(), false);
|
pair.getKey().setStoreInternal(pair.getValue().getStore(), false);
|
||||||
},
|
},
|
||||||
entry.getKey());
|
pair.getKey());
|
||||||
});
|
});
|
||||||
saveAsync();
|
saveAsync();
|
||||||
return !newChildren.isEmpty();
|
return !newChildren.isEmpty();
|
||||||
|
|
|
@ -94,6 +94,10 @@ public class DataStoreEntry extends StorageElement {
|
||||||
this.storePersistentStateNode = storePersistentState;
|
this.storePersistentStateNode = storePersistentState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static DataStoreEntry createNew(@NonNull String name, @NonNull DataStore store) {
|
||||||
|
return createNew(UUID.randomUUID(), DataStorage.get().getSelectedCategory().getUuid(), name, store);
|
||||||
|
}
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public static DataStoreEntry createNew(
|
public static DataStoreEntry createNew(
|
||||||
@NonNull UUID uuid, @NonNull UUID categoryUuid, @NonNull String name, @NonNull DataStore store) {
|
@NonNull UUID uuid, @NonNull UUID categoryUuid, @NonNull String name, @NonNull DataStore store) {
|
||||||
|
|
|
@ -28,6 +28,10 @@ public class DataStoreFormatter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String capitalize(String name) {
|
public static String capitalize(String name) {
|
||||||
|
if (name == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return name.substring(0, 1).toUpperCase()
|
return name.substring(0, 1).toUpperCase()
|
||||||
+ name.substring(1).toLowerCase();
|
+ name.substring(1).toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
package io.xpipe.app.util;
|
package io.xpipe.app.util;
|
||||||
|
|
||||||
import io.xpipe.app.storage.DataStoreEntry;
|
import io.xpipe.app.storage.DataStoreEntry;
|
||||||
|
import io.xpipe.app.storage.DataStoreEntryRef;
|
||||||
import io.xpipe.core.store.DataStore;
|
import io.xpipe.core.store.DataStore;
|
||||||
import io.xpipe.core.store.FixedChildStore;
|
import io.xpipe.core.store.FixedChildStore;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.List;
|
||||||
|
|
||||||
public interface FixedHierarchyStore extends DataStore {
|
public interface FixedHierarchyStore extends DataStore {
|
||||||
|
|
||||||
Map<String, FixedChildStore> listChildren(DataStoreEntry self) throws Exception;
|
List<? extends DataStoreEntryRef<? extends FixedChildStore>> listChildren(DataStoreEntry self) throws Exception;
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,7 +109,7 @@ public class ScriptHelper {
|
||||||
var fileName = "exec-" + getScriptId();
|
var fileName = "exec-" + getScriptId();
|
||||||
var temp = processControl.getSubTemporaryDirectory();
|
var temp = processControl.getSubTemporaryDirectory();
|
||||||
var file = FileNames.join(temp, fileName + "." + type.getScriptFileEnding());
|
var file = FileNames.join(temp, fileName + "." + type.getScriptFileEnding());
|
||||||
return createExecScript(processControl.getShellDialect(), processControl, file, content);
|
return createExecScript(type, processControl, file, content);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 646 KiB |
|
@ -6,6 +6,10 @@ none=None
|
||||||
common=Common
|
common=Common
|
||||||
key=Key
|
key=Key
|
||||||
color=Color
|
color=Color
|
||||||
|
share=Add to git repository
|
||||||
|
unshare=Remove from git repository
|
||||||
|
remove=Remove
|
||||||
|
newCategory=New subcategory
|
||||||
passwordManager=Password manager
|
passwordManager=Password manager
|
||||||
prompt=Prompt
|
prompt=Prompt
|
||||||
customCommand=Custom command
|
customCommand=Custom command
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
.category-button {
|
.category-button {
|
||||||
-fx-opacity: 0.6;
|
-fx-opacity: 0.8;
|
||||||
}
|
}
|
||||||
|
|
||||||
.category-button .settings {
|
.category-button .settings {
|
||||||
|
@ -10,7 +10,6 @@
|
||||||
-fx-underline: true ;
|
-fx-underline: true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.category:selected .category-button {
|
.category:selected .category-button {
|
||||||
-fx-opacity: 1.0;
|
-fx-opacity: 1.0;
|
||||||
-fx-background-radius: 4px;
|
-fx-background-radius: 4px;
|
||||||
|
|
|
@ -17,12 +17,12 @@
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.root:dark .background {
|
.root:dark.background {
|
||||||
-fx-opacity: 0.06;
|
-fx-background-color: linear-gradient(from 100% 0% to 0% 100%, derive(-color-bg-default, 5%) 40%, derive(-color-bg-default, 2%) 50%, derive(-color-bg-default, 5%) 100%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.root:light .background {
|
.root:light.background {
|
||||||
-fx-opacity: 0.2;
|
-fx-background-color: linear-gradient(from 100% 0% to 0% 100%, derive(-color-bg-default, -9%) 40%, derive(-color-bg-default, 1%) 50%, derive(-color-bg-default, -9%) 100%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.edit-button.icon-button-comp {
|
.edit-button.icon-button-comp {
|
||||||
|
|
|
@ -15,6 +15,10 @@ import java.util.function.Predicate;
|
||||||
|
|
||||||
public interface ShellControl extends ProcessControl {
|
public interface ShellControl extends ProcessControl {
|
||||||
|
|
||||||
|
ShellControl withTargetTerminalShellDialect(ShellDialect d);
|
||||||
|
|
||||||
|
ShellDialect getTargetTerminalShellDialect();
|
||||||
|
|
||||||
default boolean hasLocalSystemAccess() {
|
default boolean hasLocalSystemAccess() {
|
||||||
return getSystemId().equals(XPipeSystemId.getLocal());
|
return getSystemId().equals(XPipeSystemId.getLocal());
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,32 +34,23 @@ public enum PredefinedScriptStore {
|
||||||
""")
|
""")
|
||||||
.executionType(SimpleScriptStore.ExecutionType.TERMINAL_ONLY)
|
.executionType(SimpleScriptStore.ExecutionType.TERMINAL_ONLY)
|
||||||
.build()),
|
.build()),
|
||||||
STARSHIP_SETUP_UNIX("Starship Unix Setup", () -> SimpleScriptStore.builder()
|
|
||||||
.group(PredefinedScriptGroup.STARSHIP.getEntry())
|
|
||||||
.minimumDialect(ShellDialects.SH)
|
|
||||||
.commands(file("starship_setup.sh"))
|
|
||||||
.executionType(SimpleScriptStore.ExecutionType.TERMINAL_ONLY)
|
|
||||||
.build()),
|
|
||||||
STARSHIP_BASH("Starship Bash", () -> SimpleScriptStore.builder()
|
STARSHIP_BASH("Starship Bash", () -> SimpleScriptStore.builder()
|
||||||
.group(PredefinedScriptGroup.STARSHIP.getEntry())
|
.group(PredefinedScriptGroup.STARSHIP.getEntry())
|
||||||
.minimumDialect(ShellDialects.BASH)
|
.minimumDialect(ShellDialects.BASH)
|
||||||
.commands("eval \"$(starship init bash)\"")
|
.commands(file("starship_bash.sh"))
|
||||||
.executionType(SimpleScriptStore.ExecutionType.TERMINAL_ONLY)
|
.executionType(SimpleScriptStore.ExecutionType.TERMINAL_ONLY)
|
||||||
.script(STARSHIP_SETUP_UNIX.getEntry())
|
|
||||||
.build()),
|
.build()),
|
||||||
STARSHIP_ZSH("Starship Zsh", () -> SimpleScriptStore.builder()
|
STARSHIP_ZSH("Starship Zsh", () -> SimpleScriptStore.builder()
|
||||||
.group(PredefinedScriptGroup.STARSHIP.getEntry())
|
.group(PredefinedScriptGroup.STARSHIP.getEntry())
|
||||||
.minimumDialect(ShellDialects.ZSH)
|
.minimumDialect(ShellDialects.ZSH)
|
||||||
.commands("eval \"$(starship init zsh)\"")
|
.commands(file("starship_zsh.sh"))
|
||||||
.executionType(SimpleScriptStore.ExecutionType.TERMINAL_ONLY)
|
.executionType(SimpleScriptStore.ExecutionType.TERMINAL_ONLY)
|
||||||
.script(STARSHIP_SETUP_UNIX.getEntry())
|
|
||||||
.build()),
|
.build()),
|
||||||
STARSHIP_FISH("Starship Fish", () -> SimpleScriptStore.builder()
|
STARSHIP_FISH("Starship Fish", () -> SimpleScriptStore.builder()
|
||||||
.group(PredefinedScriptGroup.STARSHIP.getEntry())
|
.group(PredefinedScriptGroup.STARSHIP.getEntry())
|
||||||
.minimumDialect(ShellDialects.FISH)
|
.minimumDialect(ShellDialects.FISH)
|
||||||
.commands("starship init fish | source")
|
.commands(file("starship_fish.fish"))
|
||||||
.executionType(SimpleScriptStore.ExecutionType.TERMINAL_ONLY)
|
.executionType(SimpleScriptStore.ExecutionType.TERMINAL_ONLY)
|
||||||
.script(STARSHIP_SETUP_UNIX.getEntry())
|
|
||||||
.build()),
|
.build()),
|
||||||
STARSHIP_CMD(
|
STARSHIP_CMD(
|
||||||
"Starship Cmd",
|
"Starship Cmd",
|
||||||
|
|
|
@ -13,7 +13,9 @@ import lombok.experimental.FieldDefaults;
|
||||||
import lombok.experimental.SuperBuilder;
|
import lombok.experimental.SuperBuilder;
|
||||||
import lombok.extern.jackson.Jacksonized;
|
import lombok.extern.jackson.Jacksonized;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@SuperBuilder
|
@SuperBuilder
|
||||||
|
@ -22,7 +24,7 @@ import java.util.stream.Collectors;
|
||||||
public abstract class ScriptStore extends JacksonizedValue implements DataStore, StatefulDataStore<ScriptStore.State> {
|
public abstract class ScriptStore extends JacksonizedValue implements DataStore, StatefulDataStore<ScriptStore.State> {
|
||||||
|
|
||||||
public static ShellControl controlWithDefaultScripts(ShellControl pc) {
|
public static ShellControl controlWithDefaultScripts(ShellControl pc) {
|
||||||
return controlWithScripts(pc,getDefaultScripts());
|
return controlWithScripts(pc, getDefaultScripts());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ShellControl controlWithScripts(ShellControl pc, List<DataStoreEntryRef<ScriptStore>> refs) {
|
public static ShellControl controlWithScripts(ShellControl pc, List<DataStoreEntryRef<ScriptStore>> refs) {
|
||||||
|
@ -56,9 +58,8 @@ public abstract class ScriptStore extends JacksonizedValue implements DataStore,
|
||||||
|
|
||||||
public static List<SimpleScriptStore> flatten(List<DataStoreEntryRef<ScriptStore>> scripts) {
|
public static List<SimpleScriptStore> flatten(List<DataStoreEntryRef<ScriptStore>> scripts) {
|
||||||
var seen = new LinkedHashSet<SimpleScriptStore>();
|
var seen = new LinkedHashSet<SimpleScriptStore>();
|
||||||
scripts
|
scripts.forEach(scriptStoreDataStoreEntryRef ->
|
||||||
.forEach(scriptStoreDataStoreEntryRef ->
|
scriptStoreDataStoreEntryRef.getStore().queryFlattenedScripts(seen));
|
||||||
scriptStoreDataStoreEntryRef.getStore().queryFlattenedScripts(seen));
|
|
||||||
return seen.stream().toList();
|
return seen.stream().toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,12 +28,11 @@ public class SimpleScriptStore extends ScriptStore {
|
||||||
return assemble(shellControl, ExecutionType.TERMINAL_ONLY);
|
return assemble(shellControl, ExecutionType.TERMINAL_ONLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String assemble(
|
private String assemble(ShellControl shellControl, ExecutionType type) {
|
||||||
ShellControl shellControl, ExecutionType type) {
|
var targetType = type == ExecutionType.TERMINAL_ONLY ? shellControl.getTargetTerminalShellDialect() : shellControl.getShellDialect();
|
||||||
if ((executionType == type || executionType == ExecutionType.BOTH)
|
if ((executionType == type || executionType == ExecutionType.BOTH) && minimumDialect.isCompatibleTo(targetType)) {
|
||||||
&& minimumDialect.isCompatibleTo(shellControl.getShellDialect())) {
|
var script = ScriptHelper.createExecScript(targetType, shellControl, commands);
|
||||||
var script = ScriptHelper.createExecScript(minimumDialect, shellControl, commands);
|
return targetType.sourceScriptCommand(shellControl, script);
|
||||||
return shellControl.getShellDialect().sourceScriptCommand(shellControl, script);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -47,9 +46,11 @@ public class SimpleScriptStore extends ScriptStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void queryFlattenedScripts(LinkedHashSet<SimpleScriptStore> all) {
|
public void queryFlattenedScripts(LinkedHashSet<SimpleScriptStore> all) {
|
||||||
getEffectiveScripts().stream().filter(scriptStoreDataStoreEntryRef -> !all.contains(scriptStoreDataStoreEntryRef.getStore())).forEach(scriptStoreDataStoreEntryRef -> {
|
getEffectiveScripts().stream()
|
||||||
scriptStoreDataStoreEntryRef.getStore().queryFlattenedScripts(all);
|
.filter(scriptStoreDataStoreEntryRef -> !all.contains(scriptStoreDataStoreEntryRef.getStore()))
|
||||||
});
|
.forEach(scriptStoreDataStoreEntryRef -> {
|
||||||
|
scriptStoreDataStoreEntryRef.getStore().queryFlattenedScripts(all);
|
||||||
|
});
|
||||||
all.add(this);
|
all.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
dir=~/.xpipe/scriptdata/starship
|
||||||
|
export PATH="$PATH:$dir"
|
||||||
|
which starship > /dev/null
|
||||||
|
if [ "$?" != 0 ]; then
|
||||||
|
mkdir -p "$dir" && \
|
||||||
|
which curl > /dev/null && \
|
||||||
|
curl -sS https://starship.rs/install.sh | sh /dev/stdin -y --bin-dir "$dir" > /dev/null
|
||||||
|
fi
|
||||||
|
eval "$(starship init bash)"
|
|
@ -0,0 +1,9 @@
|
||||||
|
set dir ~/.xpipe/scriptdata/starship
|
||||||
|
export PATH="$PATH:$dir"
|
||||||
|
which starship > /dev/null
|
||||||
|
if [ $status != 0 ]
|
||||||
|
mkdir -p "$dir" && \
|
||||||
|
which curl > /dev/null && \
|
||||||
|
curl -sS https://starship.rs/install.sh | sh /dev/stdin -y --bin-dir "$dir" > /dev/null
|
||||||
|
end
|
||||||
|
starship init fish | source
|
|
@ -1,7 +0,0 @@
|
||||||
dir=~/.xpipe/scriptdata/starship
|
|
||||||
export PATH="$PATH:$dir"
|
|
||||||
which starship > /dev/null
|
|
||||||
if [ "$?" != 0 ]; then
|
|
||||||
mkdir -p "$dir"
|
|
||||||
sh <(curl -sS https://starship.rs/install.sh) -y --bin-dir "$dir" > /dev/null
|
|
||||||
fi
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
dir=~/.xpipe/scriptdata/starship
|
||||||
|
export PATH="$PATH:$dir"
|
||||||
|
which starship > /dev/null
|
||||||
|
if [ "$?" != 0 ]; then
|
||||||
|
mkdir -p "$dir" && \
|
||||||
|
which curl > /dev/null && \
|
||||||
|
curl -sS https://starship.rs/install.sh | sh /dev/stdin -y --bin-dir "$dir" > /dev/null
|
||||||
|
fi
|
||||||
|
eval "$(starship init zsh)"
|
Loading…
Reference in a new issue