Skip to content

Commit f9cfa95

Browse files
authored
Merge pull request #179 from filip26/fix/issue-176
Fix compression output to stdout
2 parents 0d6bd0f + 845b072 commit f9cfa95

File tree

7 files changed

+21
-28
lines changed

7 files changed

+21
-28
lines changed

.github/workflows/java-build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ jobs:
2424

2525
steps:
2626
- uses: actions/checkout@v2
27-
- name: Set up JDK 24
27+
- name: Set up JDK 25
2828
uses: actions/setup-java@v1
2929
with:
30-
java-version: 24
30+
java-version: 25
3131
- name: Build with Maven
3232
env:
3333
GITHUB_ACTOR: ${{ github.actor }}

.github/workflows/native-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
uses: graalvm/setup-graalvm@v1
3333
with:
3434
version: 'latest'
35-
java-version: '24'
35+
java-version: 25
3636
components: 'native-image'
3737
github-token: ${{ secrets.GITHUB_TOKEN }}
3838

README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,6 @@ All PR's welcome!
151151
* [Copper Multibase](https://github.com/filip26/copper-multibase)
152152
* [Copper Multicodec](https://github.com/filip26/copper-multicodec)
153153

154-
## Sponsors
155-
156-
<a href="https://github.com/thadguidry">
157-
<img src="https://avatars.githubusercontent.com/u/986438?v=4" width="40" />
158-
</a>
159-
160154
## Commercial Support
161155

162156
Commercial support and consulting are available.

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<modelVersion>4.0.0</modelVersion>
77
<groupId>com.apicatalog</groupId>
88
<artifactId>ld-cli</artifactId>
9-
<version>1.0.1</version>
9+
<version>1.0.2</version>
1010
<packaging>jar</packaging>
1111

1212
<name>A Command Line Processor for Linked Data Processing</name>
@@ -21,8 +21,8 @@
2121
<url>https://github.com/filip26/ld-cli</url>
2222

2323
<properties>
24-
<maven.compiler.target>24</maven.compiler.target>
25-
<maven.compiler.source>24</maven.compiler.source>
24+
<maven.compiler.target>25</maven.compiler.target>
25+
<maven.compiler.source>25</maven.compiler.source>
2626
<maven.compiler.showDeprecation>true</maven.compiler.showDeprecation>
2727

2828
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

snapcraft.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: ld-cli
22
title: Linked Data CLI
3-
version: 1.0.1
3+
version: 1.0.2
44
license: Apache-2.0
55
summary: Command-line tool for JSON-LD, RDF, RDFC, JCS, CBOR-LD, semantic processing
66
description: |
@@ -26,14 +26,14 @@ grade: stable
2626
parts:
2727
graalvm:
2828
plugin: nil
29-
source: https://download.oracle.com/graalvm/24/latest/graalvm-jdk-24_linux-x64_bin.tar.gz
29+
source: https://download.oracle.com/graalvm/25/latest/graalvm-jdk-25_linux-x64_bin.tar.gz
3030
build-packages:
3131
- wget
3232
- tar
3333
override-build: |
3434
echo "=== Entering GraalVM override-build ==="
3535
mkdir -p $SNAPCRAFT_STAGE/opt
36-
wget -qO- https://download.oracle.com/graalvm/24/latest/graalvm-jdk-24_linux-x64_bin.tar.gz | tar xz -C $SNAPCRAFT_STAGE/opt
36+
wget -qO- https://download.oracle.com/graalvm/25/latest/graalvm-jdk-25_linux-x64_bin.tar.gz | tar xz -C $SNAPCRAFT_STAGE/opt
3737
GRAALVM_DIR=$(find $SNAPCRAFT_STAGE/opt -maxdepth 1 -type d -name "graalvm-*")
3838
3939
if [ -z "$GRAALVM_DIR" ]; then
@@ -59,7 +59,7 @@ parts:
5959
export PATH=$JAVA_HOME/bin:$PATH
6060
echo "JAVA_HOME is set to: $JAVA_HOME" # For debugging purposes
6161
echo "PATH is set to: $PATH" # For debugging purposes
62-
mvn clean package -Pnative
62+
mvn package -Pnative
6363
mkdir -p $SNAPCRAFT_PART_INSTALL/bin
6464
cp target/ld-cli $SNAPCRAFT_PART_INSTALL/bin/
6565

src/main/java/com/apicatalog/cli/App.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
MultibaseCmd.class,
3636
MulticodecCmd.class,
3737
}, mixinStandardHelpOptions = false, descriptionHeading = "%n", parameterListHeading = "%nParameters:%n", optionListHeading = "%nOptions:%n", commandListHeading = "%nCommands:%n", version = {
38-
"ld-cli 1.0.1 https://github.com/filip26/ld-cli",
39-
"titanium-json-ld 1.6.0 https://github.com/filip26/titanium-json-ld",
38+
"ld-cli 1.0.2 https://github.com/filip26/ld-cli",
39+
"titanium-json-ld 1.7.0 https://github.com/filip26/titanium-json-ld",
4040
"titanium-rdfc 2.0.0 https://github.com/filip26/titanium-rdf-canon",
4141
"titanium-jcs 1.0.0 https://github.com/filip26/titanium-jcs",
4242
"iridium-cbor-ld 0.7.3 https://github.com/filip26/iridium-cbor-ld",

src/main/java/com/apicatalog/cli/command/CompressCmd.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.apicatalog.cli.command;
22

33
import java.io.FileOutputStream;
4-
import java.io.IOException;
54
import java.net.URI;
5+
import java.nio.charset.StandardCharsets;
66
import java.util.concurrent.Callable;
77

88
import com.apicatalog.base.Base16;
@@ -41,7 +41,7 @@ public final class CompressCmd implements Callable<Integer> {
4141
@Option(names = { "-d", "--dictionary" }, description = "Custom dictionary location (JSON).", paramLabel = "<uri|file>")
4242
URI dictionary = null;
4343

44-
@Option(names = { "-x", "--hex" }, description = "Output result as hexadecimal-encoded.")
44+
@Option(names = { "-x", "--hex" }, description = "Output result as hexadecimal-encoded. Automatically enabled for stdout.")
4545
boolean hex = false;
4646

4747
@Mixin
@@ -85,22 +85,21 @@ public Integer call() throws Exception {
8585
.encode(json.asJsonObject());
8686

8787
if (output == null) {
88-
spec.commandLine().getOut().print(encode(encoded, hex));
88+
spec.commandLine().getOut().print(Base16.encode(encoded, Base16.ALPHABET_LOWER));
8989
spec.commandLine().getOut().flush();
9090

9191
} else {
9292
try (var os = new FileOutputStream(output)) {
93-
os.write(encode(encoded, hex));
93+
if (hex) {
94+
os.write(Base16.encode(encoded, Base16.ALPHABET_LOWER).getBytes(StandardCharsets.UTF_8));
95+
} else {
96+
os.write(encoded);
97+
}
98+
9499
os.flush();
95100
}
96101
}
97102

98103
return spec.exitCodeOnSuccess();
99104
}
100-
101-
static byte[] encode(byte[] encoded, boolean hex) throws IOException {
102-
return hex
103-
? Base16.encode(encoded, Base16.ALPHABET_LOWER).getBytes()
104-
: encoded;
105-
}
106105
}

0 commit comments

Comments
 (0)