Skip to content

Commit

Permalink
Reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
crschnick committed Oct 17, 2024
1 parent c084a55 commit f0fe0d7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
6 changes: 1 addition & 5 deletions app/src/main/java/io/xpipe/app/prefs/LoggingCategory.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.util.DesktopHelper;
import io.xpipe.app.util.LicenseProvider;
import io.xpipe.app.util.LicensedFeature;
import io.xpipe.app.util.OptionsBuilder;

import java.io.IOException;
Expand All @@ -25,10 +24,7 @@ protected Comp<?> create() {
var prefs = AppPrefs.get();
var feature = LicenseProvider.get().getFeature("logging");
var supported = feature.isSupported() || feature.isPreviewSupported();
var title = AppI18n.observable("sessionLogging")
.map(s -> s + (supported
? ""
: " (Pro)"));
var title = AppI18n.observable("sessionLogging").map(s -> s + (supported ? "" : " (Pro)"));
return new OptionsBuilder()
.addTitle(title)
.sub(new OptionsBuilder()
Expand Down
29 changes: 18 additions & 11 deletions app/src/main/java/io/xpipe/app/util/TerminalLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ public static void open(DataStoreEntry entry, String title, String directory, Pr
var log = AppPrefs.get().enableTerminalLogging().get();
var terminalConfig = new TerminalInitScriptConfig(
adjustedTitle,
!log && type.shouldClear() && AppPrefs.get().clearTerminalOnInit().get(),
!log
&& type.shouldClear()
&& AppPrefs.get().clearTerminalOnInit().get(),
cc instanceof ShellControl ? type.additionalInitCommands() : TerminalInitFunction.none());
var request = UUID.randomUUID();
var config = createConfig(request, entry, cleanTitle, adjustedTitle);
Expand Down Expand Up @@ -97,8 +99,7 @@ private static ExternalTerminalType.LaunchConfiguration createConfig(
var preparationScript = ScriptHelper.createLocalExecScript(launcherScript);

var feature = LicenseProvider.get().getFeature("logging");
var supported = feature
.isSupported();
var supported = feature.isSupported();
if (!supported) {
throw new LicenseRequiredException(feature);
}
Expand Down Expand Up @@ -134,23 +135,29 @@ private static ExternalTerminalType.LaunchConfiguration createConfig(
entry != null ? color : null, adjustedTitle, cleanTitle, ps, ShellDialects.POWERSHELL);
return config;
} else {
var found = sc.command(sc.getShellDialect().getWhichCommand("script")).executeAndCheck();
var found = sc.command(sc.getShellDialect().getWhichCommand("script"))
.executeAndCheck();
if (!found) {
var suffix = sc.getOsType() == OsType.MACOS ? "This command is available in the util-linux package which can be installed via homebrew." : "This command is available in the util-linux package.";
throw ErrorEvent.expected(new IllegalStateException("Logging requires the script command to be installed. " + suffix));
var suffix = sc.getOsType() == OsType.MACOS
? "This command is available in the util-linux package which can be installed via homebrew."
: "This command is available in the util-linux package.";
throw ErrorEvent.expected(new IllegalStateException(
"Logging requires the script command to be installed. " + suffix));
}

var content = sc.getOsType() == OsType.MACOS || sc.getOsType() == OsType.BSD ?
"""
var content = sc.getOsType() == OsType.MACOS || sc.getOsType() == OsType.BSD
? """
echo "Transcript started, output file is sessions/%s"
script -e -q "%s" "%s"
echo "Transcript stopped, output file is sessions/%s"
""".formatted(logFile.getFileName(), logFile, preparationScript, logFile.getFileName()) :
"""
"""
.formatted(logFile.getFileName(), logFile, preparationScript, logFile.getFileName())
: """
echo "Transcript started, output file is sessions/%s"
script --quiet --command "%s" "%s"
echo "Transcript stopped, output file is sessions/%s"
""".formatted(logFile.getFileName(), preparationScript, logFile, logFile.getFileName());
"""
.formatted(logFile.getFileName(), preparationScript, logFile, logFile.getFileName());
var ps = ScriptHelper.createExecScript(sc.getShellDialect(), sc, content);
var config = new ExternalTerminalType.LaunchConfiguration(
entry != null ? color : null, adjustedTitle, cleanTitle, ps, sc.getShellDialect());
Expand Down

0 comments on commit f0fe0d7

Please sign in to comment.