Skip to content

Commit 37eb5c0

Browse files
committed
Remove JLine in SNAP
1 parent f4b3163 commit 37eb5c0

File tree

4 files changed

+23
-18
lines changed

4 files changed

+23
-18
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,4 +276,4 @@ val generateChecksums by tasks.registering {
276276
println("Generated $outName in build/libs")
277277
}
278278
}
279-
}
279+
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ org.gradle.caching=false
1111
org.gradle.console=colored
1212

1313
# Cal Program Version
14-
version=3.0.1
14+
version=3.0.2
1515

1616
# Cal Inception Date
1717
inceptionYear=2018

snap/snapcraft.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: fcal
22
title: fCal
3-
version: '3.0.1'
3+
version: '3.0.2'
44
summary: Command line calendar display
55
description: |
66
fCal is a command line calendar utility. It will display a

src/main/java/org/fross/cal/Main.java

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,15 @@ public class Main {
5151
* @param args
5252
*/
5353
public static void main(String[] args) {
54-
// Process application level properties file
55-
// Update properties from Maven at build time:
56-
// https://stackoverflow.com/questions/3697449/retrieve-version-from-maven-pom-xml-in-code
57-
try {
58-
InputStream iStream = Main.class.getClassLoader().getResourceAsStream(PROPERTIES_FILE);
59-
Properties prop = new Properties();
60-
prop.load(iStream);
61-
VERSION = prop.getProperty("Application.version");
62-
COPYRIGHT = "Copyright " + prop.getProperty("Application.inceptionYear") + "-" + org.fross.library.Date.getCurrentYear() + " by Michael Fross";
63-
} catch (IOException ex) {
64-
Output.fatalError("Unable to read property file '" + PROPERTIES_FILE + "'", 3);
65-
}
66-
6754
// Force JLine to assume the terminal supports ANSI color and movement
6855
System.setProperty("org.jline.terminal.type", "xterm-256color");
56+
57+
// Suppress JLine warnings when running in confined environments (like snaps)
58+
// JLine can't access /dev/tty in strict confinement, so it falls back to dumb terminal
59+
// Colors still work fine via ANSI codes, so just suppress the warning
60+
if (System.getenv("SNAP") != null || System.getenv("SNAP_NAME") != null) {
61+
java.util.logging.Logger.getLogger("org.jline").setLevel(java.util.logging.Level.SEVERE);
62+
}
6963

7064
// Create a terminal used for output with JLine
7165
try {
@@ -82,7 +76,18 @@ public static void main(String[] args) {
8276

8377
} catch (IOException ex) {
8478
// Note: Since terminal failed, we use System.out as a fallback
85-
Output.println("Unable to create a terminal. Visuals will be impacted");
79+
Output.println("Unable to create a terminal. Visuals may be impacted");
80+
}
81+
82+
// Process application level properties file
83+
try {
84+
InputStream iStream = Main.class.getClassLoader().getResourceAsStream(PROPERTIES_FILE);
85+
Properties prop = new Properties();
86+
prop.load(iStream);
87+
VERSION = prop.getProperty("Application.version");
88+
COPYRIGHT = "Copyright " + prop.getProperty("Application.inceptionYear") + "-" + org.fross.library.Date.getCurrentYear() + " by Michael Fross";
89+
} catch (IOException ex) {
90+
Output.fatalError("Unable to read property file '" + PROPERTIES_FILE + "'", 3);
8691
}
8792

8893
// Process the command line arguments and switches
@@ -147,4 +152,4 @@ public static void main(String[] args) {
147152
break;
148153
}
149154
}
150-
}
155+
}

0 commit comments

Comments
 (0)