Skip to content

Commit

Permalink
Apply review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasBrand committed Oct 7, 2024
1 parent 4f3693b commit 2d063b0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 21 deletions.
37 changes: 18 additions & 19 deletions src/main/java/com/hivemq/cli/commands/options/SubscribeOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ private void userProperties(final @NotNull Mqtt5UserProperty @NotNull [] userPro
@CommandLine.Option(names = {"-up", "--userProperty"},
hidden = true,
converter = Mqtt5UserPropertyConverter.class,
description = "Options \"-up\" and \"--userProperty\" are legacy, please use \"--user-property\". They will be removed in a future version.")
description = "Options \"-up\" and \"--userProperty\" are legacy, please use \"--user-property\". Legacy options will be removed in a future version.")
private void userPropertiesLegacy(final @NotNull Mqtt5UserProperty @NotNull [] userPropertiesLegacy) {
//only show message once as this method is executed multiple times
if (!userPropertiesFromLegacyOption) {
deprecationWarnings.add(
"Options \"-up\" and \"--userProperty\" are legacy, please use \"--user-property\". They will be removed in a future version.");
"Options \"-up\" and \"--userProperty\" are legacy, please use \"--user-property\". Legacy options will be removed in a future version.");
}

if (userPropertiesFromOption) {
Expand Down Expand Up @@ -110,10 +110,10 @@ private void outputFile(final @NotNull File outputFile) {
@Deprecated(since = "4.34.0", forRemoval = true)
@CommandLine.Option(names = {"-of", "--outputToFile"},
hidden = true,
description = "Options \"-of\" and \"--outputToFile\" are legacy, please use \"--output-to-file\". They will be removed in a future version")
description = "Options \"-of\" and \"--outputToFile\" are legacy, please use \"--output-to-file\". Legacy options will be removed in a future version")
private void outputFileLegacy(final @NotNull File outputFileLegacy) {
deprecationWarnings.add(
"Options \"-of\" and \"--outputToFile\" are legacy, please use \"--output-to-file\". They will be removed in a future version.");
"Options \"-of\" and \"--outputToFile\" are legacy, please use \"--output-to-file\". Legacy options will be removed in a future version.");

if (this.outputFile != null) {
throw new CommandLine.ParameterException(spec.commandLine(),
Expand All @@ -122,33 +122,33 @@ private void outputFileLegacy(final @NotNull File outputFileLegacy) {
this.outputFile = outputFileLegacy;
}

private boolean isPayloadEncodeToBase64 = false;
private boolean isEncodePayloadInBase64 = false;

@SuppressWarnings("unused")
@CommandLine.Option(names = {"--base64"},
description = "Specify the encoding of the received messages as Base64 (default: false)")
private void isMessageBase64Encoded(final boolean base64) {
if (isPayloadEncodeToBase64) {
if (isEncodePayloadInBase64) {
throw new CommandLine.ParameterException(spec.commandLine(),
"A mix of the base64 legacy options \"-b64\" and the current \"--base64\" is used. Please only use \"--base64\" as the legacy options will be removed in a future version.");
}
isPayloadEncodeToBase64 = base64;
isEncodePayloadInBase64 = base64;
}

@SuppressWarnings("unused")
@Deprecated(since = "4.34.0", forRemoval = true)
@CommandLine.Option(names = {"-b64"},
hidden = true,
description = "Option \"-b64\" is legacy, please use \"--base64\". It will be removed in a future version")
description = "Option \"-b64\" is legacy, please use \"--base64\". The legacy option will be removed in a future version")
private void isMessageBase64EncodedLegacy(final boolean base64Legacy) {
deprecationWarnings.add(
"Option \"-b64\" is legacy, please use \"--base64\". It will be removed in a future version.");
"Option \"-b64\" is legacy, please use \"--base64\". The legacy option will be removed in a future version.");

if (isPayloadEncodeToBase64) {
if (isEncodePayloadInBase64) {
throw new CommandLine.ParameterException(spec.commandLine(),
"A mix of the base64 legacy options \"-b64\" and the current \"--base64\" is used. Please only use \"--base64\" as the legacy options will be removed in a future version.");
}
isPayloadEncodeToBase64 = base64Legacy;
isEncodePayloadInBase64 = base64Legacy;
}

private boolean jsonOutput = false;
Expand All @@ -168,10 +168,10 @@ private void jsonOutput(final boolean jsonOutput) {
@Deprecated(since = "4.34.0", forRemoval = true)
@CommandLine.Option(names = {"--jsonOutput"},
hidden = true,
description = "Option \"--jsonOutput\" is legacy, please use \"--json-output\". It will be removed in a future version")
description = "Option \"--jsonOutput\" is legacy, please use \"--json-output\". The legacy option will be removed in a future version")
private void jsonOutputLegacy(final boolean jsonOutputLegacy) {
deprecationWarnings.add(
"Option \"--jsonOutput\" is legacy, please use \"--json-output\". It will be removed in a future version.");
"Option \"--jsonOutput\" is legacy, please use \"--json-output\". The legacy option will be removed in a future version.");

if (jsonOutput) {
throw new CommandLine.ParameterException(spec.commandLine(),
Expand All @@ -197,10 +197,10 @@ private void showTopics(final boolean showTopics) {
@Deprecated(since = "4.34.0", forRemoval = true)
@CommandLine.Option(names = {"--showTopics"},
hidden = true,
description = "Option \"--showTopics\" is legacy, please use \"-T\" or \"--show-topics\". It will be removed in a future version")
description = "Option \"--showTopics\" is legacy, please use \"-T\" or \"--show-topics\". The legacy option will be removed in a future version")
private void showTopicsLegacy(final boolean showTopicsLegacy) {
deprecationWarnings.add(
"Option \"--showTopics\" is legacy, please use \"-T\" or \"--show-topics\". It will be removed in a future version.");
"Option \"--showTopics\" is legacy, please use \"-T\" or \"--show-topics\". The legacy option will be removed in a future version.");

if (this.showTopics) {
throw new CommandLine.ParameterException(spec.commandLine(),
Expand Down Expand Up @@ -232,8 +232,8 @@ public boolean isPrintToSTDOUT() {
return printToSTDOUT;
}

public boolean isPayloadEncodeToBase64() {
return isPayloadEncodeToBase64;
public boolean isEncodePayloadInBase64() {
return isEncodePayloadInBase64;
}

public boolean isJsonOutput() {
Expand Down Expand Up @@ -314,8 +314,7 @@ public void setDefaultOptions() {
outputFile +
", printToSTDOUT=" +
printToSTDOUT +
", base64=" +
isPayloadEncodeToBase64 +
", base64=" + isEncodePayloadInBase64 +
", jsonOutput=" +
jsonOutput +
", showTopics=" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class SubscribeMqtt3PublishCallback implements Consumer<Mqtt3Publish> {
SubscribeMqtt3PublishCallback(final @NotNull SubscribeOptions subscribeOptions, final @NotNull Mqtt3Client client) {
printToStdout = subscribeOptions.isPrintToSTDOUT();
outputFile = subscribeOptions.getOutputFile();
isBase64 = subscribeOptions.isPayloadEncodeToBase64();
isBase64 = subscribeOptions.isEncodePayloadInBase64();
isJsonOutput = subscribeOptions.isJsonOutput();
showTopics = subscribeOptions.isShowTopics();
this.client = client;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class SubscribeMqtt5PublishCallback implements Consumer<Mqtt5Publish> {
SubscribeMqtt5PublishCallback(final @NotNull SubscribeOptions subscribeOptions, final @NotNull Mqtt5Client client) {
printToStdout = subscribeOptions.isPrintToSTDOUT();
outputFile = subscribeOptions.getOutputFile();
isBase64 = subscribeOptions.isPayloadEncodeToBase64();
isBase64 = subscribeOptions.isEncodePayloadInBase64();
isJsonOutput = subscribeOptions.isJsonOutput();
showTopics = subscribeOptions.isShowTopics();
this.client = client;
Expand Down

0 comments on commit 2d063b0

Please sign in to comment.