Skip to content

Commit

Permalink
improve mobile help command
Browse files Browse the repository at this point in the history
  • Loading branch information
sanshengshui committed Dec 14, 2023
1 parent 365b672 commit 28b220d
Show file tree
Hide file tree
Showing 7 changed files with 187 additions and 86 deletions.
6 changes: 4 additions & 2 deletions toolkit-app/src/main/resources/i18n/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,14 @@ nb.cmd.imei.desc=the device imei
nb.cmd.name.desc=the device name
nb.cmd.imsi.desc=the device imsi,a 16-bit string of uppercase and lowercase letters plus 0-9 digits
nb.cmd.notObserv.desc=whether to auto observer
nb.cmd.obsv.desc=whether to auto observer
nb.cmd.pskType.desc=the pskType,0-char, 1-hex
nb.cmd.pskValue.desc=the pskValue,The value contains a maximum of 15 digits, ranging from 0 to 9
nb.cmd.psk.desc=dtls specifies the psk used for encryption. It is 8 to 16 bytes long and consists of letters or numbers
nb.cmd.hex.desc=messages will be hex decoded.
nb.cmd.limit.desc=the limit of data list
nb.cmd.startTime.desc=start time of search device log data list
nb.cmd.endTime.desc=end time of search device log data list
nb.cmd.startTime.desc=start time of search data list
nb.cmd.endTime.desc=end time of search data list

##NB prompt
nbType.prompt=Please select the Nb-IoT type
Expand Down
6 changes: 4 additions & 2 deletions toolkit-app/src/main/resources/i18n/messages_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,14 @@ nb.cmd.imei.desc=the device imei
nb.cmd.name.desc=the device name
nb.cmd.imsi.desc=the device imsi,a 16-bit string of uppercase and lowercase letters plus 0-9 digits
nb.cmd.notObserv.desc=whether to auto observer
nb.cmd.obsv.desc=whether to auto observer
nb.cmd.pskType.desc=the pskType,0-char, 1-hex
nb.cmd.pskValue.desc=the pskValue,The value contains a maximum of 15 digits, ranging from 0 to 9
nb.cmd.psk.desc=dtls specifies the psk used for encryption. It is 8 to 16 bytes long and consists of letters or numbers
nb.cmd.hex.desc=messages will be hex decoded.
nb.cmd.limit.desc=the limit of data list
nb.cmd.startTime.desc=start time of search device log data list
nb.cmd.endTime.desc=end time of search device log data list
nb.cmd.startTime.desc=start time of search data list
nb.cmd.endTime.desc=end time of search data list

##NB prompt
nbType.prompt=Please select the Nb-IoT type
Expand Down
6 changes: 4 additions & 2 deletions toolkit-app/src/main/resources/i18n/messages_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,14 @@ nb.cmd.imei.desc=the device imei
nb.cmd.name.desc=the device name
nb.cmd.imsi.desc=the device imsi,a 16-bit string of uppercase and lowercase letters plus 0-9 digits
nb.cmd.notObserv.desc=whether to auto observer
nb.cmd.obsv.desc=whether to auto observer
nb.cmd.pskType.desc=the pskType,0-char, 1-hex
nb.cmd.pskValue.desc=the pskValue,The value contains a maximum of 15 digits, ranging from 0 to 9
nb.cmd.psk.desc=dtls specifies the psk used for encryption. It is 8 to 16 bytes long and consists of letters or numbers
nb.cmd.hex.desc=messages will be hex decoded.
nb.cmd.limit.desc=the limit of data list
nb.cmd.startTime.desc=start time of search device log data list
nb.cmd.endTime.desc=end time of search device log data list
nb.cmd.startTime.desc=start time of search data list
nb.cmd.endTime.desc=end time of search data list

##NB prompt
nbType.prompt=Please select the Nb-IoT type
Expand Down
6 changes: 4 additions & 2 deletions toolkit-app/src/main/resources/i18n/messages_zh.properties
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,14 @@ nb.cmd.imei.desc=\u8bbe\u5907\u7684imei(\u5fc5\u586b)
nb.cmd.name.desc=\u8bbe\u5907\u7684\u540d\u79f0(\u589e\u52a0\u8bbe\u5907\u5fc5\u586b\uff0c\u66f4\u65b0\u65f6\u9009\u586b)
nb.cmd.imsi.desc=\u8bbe\u5907\u7684imsi \u603b\u957f\u5ea6\u4e0d\u8d85\u8fc715\u4f4d \u4f7f\u75280~9\u7684\u6570\u5b57(\u9009\u586b)
nb.cmd.notObserv.desc=\u662f\u5426\u8ba2\u9605(\u9009\u586b)
nb.cmd.obsv.desc=\u662f\u5426\u8ba2\u9605(\u9009\u586b)
nb.cmd.pskType.desc=\u53d6\u503c0\u6216\u80051 0\u4ee3\u8868\u666e\u901a\u5b57\u7b26\u4e32 1\u4ee3\u886816\u8fdb\u5236\u5b57\u7b26\u4e32(\u9009\u586b)
nb.cmd.pskValue.desc=\u7531\u5927\u5c0f\u5199\u5b57\u6bcd\u52a00-9\u6570\u5b57\u7ec4\u6210\u768416\u4f4d\u5b57\u7b26\u4e32(\u9009\u586b)
nb.cmd.psk.desc=dtls\u52a0\u5bc6\u6240\u4f7f\u7528\u7684psk\uff0c\u957f\u5ea68-16\u4e2a\u5b57\u8282\uff0c\u5b57\u6bcd\u6216\u6570\u5b57\u7ec4\u6210
nb.cmd.hex.desc=\u6d88\u606f\u5c06\u88ab\u5341\u516d\u8fdb\u5236\u89e3\u7801(\u65e0\u7269\u6a21\u578b\u65f6\u751f\u6548).
nb.cmd.limit.desc=\u6570\u636e\u5217\u8868\u6761\u6570(\u9009\u586b)
nb.cmd.startTime.desc=\u641c\u7d22\u8bbe\u5907\u65e5\u5fd7\u6570\u636e\u5217\u8868\u7684\u8d77\u59cb\u65f6\u95f4(\u9ed8\u8ba4\u662f\u5f53\u592900:00:00,\u9009\u586b)
nb.cmd.endTime.desc=\u67e5\u8be2\u8bbe\u5907\u65e5\u5fd7\u6570\u636e\u5217\u8868\u7684\u7ed3\u675f\u65f6\u95f4(\u9ed8\u8ba4\u662f\u5f53\u592923:59:59,\u9009\u586b)
nb.cmd.startTime.desc=\u641c\u7d22\u6570\u636e\u5217\u8868\u7684\u8d77\u59cb\u65f6\u95f4(\u683c\u5f0f\u4e3a:2015-01-10T08:00:35, \u9ed8\u8ba4\u662f\u5f53\u592900:00:00,\u9009\u586b)
nb.cmd.endTime.desc=\u641c\u7d22\u6570\u636e\u5217\u8868\u7684\u7ed3\u675f\u65f6\u95f4(\u683c\u5f0f\u4e3a:2015-01-10T08:00:35, \u9ed8\u8ba4\u662f\u5f53\u592923:59:59,\u9009\u586b)

##NB prompt
nbType.prompt=\u8bf7\u9009\u62e9 Nb-IoT \u5e73\u53f0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ public boolean call(MobileConfigDomain mobileConfigDomain, Terminal terminal) {
boolean isEnd = true;
MobProcessContext context = new MobProcessContext();
context.setMobileConfigDomain(mobileConfigDomain);

var mobHelpProcessor = new MobHelpProcessor();
mobHelpProcessor.printAllHelpInfo();
while (isEnd) {
String data;
data = reader.readLine(prompt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,116 +49,205 @@ public void handle(ProcessContext context) {
}
//user type help
if (arguArgs.size() == 1) {
StringBuilder sb = new StringBuilder();
// list telecom nb-iot devices
sb.append(ColorUtils.cyanAnnotation("list: " + bundle.getString("nb.operation.list.desc")))
.append(StringUtils.lineSeparator());
sb.append(" usage: list [searchValue] [pageNo]").append(StringUtils.lineSeparator());
sb.append(StringUtils.lineSeparator());

// get telecom nb-iot device detail info
sb.append(ColorUtils.cyanAnnotation("show: " + bundle.getString("nb.operation.get.desc")))
.append(StringUtils.lineSeparator());
sb.append(" usage: show imei").append(StringUtils.lineSeparator());
sb.append(StringUtils.lineSeparator());

// delete telecom nb-iot device
sb.append(ColorUtils.cyanAnnotation("del: " + bundle.getString("nb.operation.del.desc")))
.append(StringUtils.lineSeparator());
sb.append(" usage: del imei").append(StringUtils.lineSeparator());
sb.append(StringUtils.lineSeparator());

// add telecom nb-iot device
sb.append(ColorUtils.cyanAnnotation("add: " + bundle.getString("nb.operation.add.desc")))
.append(StringUtils.lineSeparator());
sb.append(" usage: add imei name").append(StringUtils.lineSeparator());
sb.append(StringUtils.lineSeparator());

// update telecom nb-iot device name
sb.append(ColorUtils.cyanAnnotation("update: " + bundle.getString("nb.operation.update.desc")))
.append(StringUtils.lineSeparator());
sb.append(" usage: update imei name").append(StringUtils.lineSeparator());
sb.append(StringUtils.lineSeparator());

// print telecom nb-iot device reported data
sb.append(ColorUtils.cyanAnnotation("log: " + bundle.getString("nb.operation.log.desc")))
.append(StringUtils.lineSeparator());
sb.append(" usage: log imei [startTime] [endTime] [limit]").append(StringUtils.lineSeparator());
sb.append(StringUtils.lineSeparator());

// print telecom nb-iot device command data
sb.append(ColorUtils.cyanAnnotation("command: " + bundle.getString("nb.operation.command.desc")))
.append(StringUtils.lineSeparator());
sb.append(" usage: command imei startTime [pageNo]").append(StringUtils.lineSeparator());
System.out.format(sb.toString());
printAllHelpInfo();
return;
}
String subCommand = arguArgs.get(1);
StringBuilder sb = new StringBuilder();
switch (subCommand) {
case "list":
sb.append(ColorUtils.cyanAnnotation("list: " + bundle.getString("nb.operation.list.desc")))
case "ls":
sb.append(ColorUtils.colorBold("Usage: ", "black")
+ String.format("> %s [%s <searchValue>] [%s <pageNo>] [%s <pageSize>]",
ColorUtils.colorBold("ls,list", "green"),
ColorUtils.colorBold("-sv", "green"),
ColorUtils.colorBold("-pn", "green"),
ColorUtils.colorBold("-ps", "green")));
sb.append(StringUtils.lineSeparator());
sb.append(bundle.getString("nb.operation.list.desc")).append(StringUtils.lineSeparator());
sb.append(StringUtils.lineSeparator());
sb.append("Options:").append(StringUtils.lineSeparator());
sb.append(String.format("%s %s",
ColorUtils.colorBold("-sv --searchValue ", "green"),
bundle.getString("nb.cmd.sv.desc")))
.append(StringUtils.lineSeparator());
sb.append(String.format("%s %s",
ColorUtils.colorBold("-pn --pageNo ", "green"),
bundle.getString("nb.cmd.pn.desc")))
.append(StringUtils.lineSeparator());
sb.append(" usage: ").append(StringUtils.lineSeparator());
sb.append(" - list : print first page device list").append(StringUtils.lineSeparator());
sb.append(" - list pageNo : print pageNo device list").append(StringUtils.lineSeparator());
sb.append(" - list searchValue pageNo : print keywords:searchValue, page number:pageNo device list" )
sb.append(String.format("%s %s",
ColorUtils.colorBold("-ps --pageSize ", "green"),
bundle.getString("nb.cmd.ps.desc")))
.append(StringUtils.lineSeparator());
sb.append(" searchValue support name、deviceId" ).append(StringUtils.lineSeparator());
System.out.format(sb.toString());
System.out.print(sb);
break;
case "add":
sb.append(ColorUtils.cyanAnnotation("add: " + bundle.getString("nb.operation.add.desc")))
.append(StringUtils.lineSeparator());
sb.append(" usage: add imei name").append(StringUtils.lineSeparator());
sb.append(ColorUtils.colorBold("Usage: ", "black")
+ String.format("> %s %s <imei> %s <name> [%s] [%s <imsi>] [%s <psk>]",
ColorUtils.colorBold("add", "green"),
ColorUtils.colorBold("-imei", "green"),
ColorUtils.colorBold("-name", "green"),
ColorUtils.colorBold("-obsv", "green"),
ColorUtils.colorBold("-imsi", "green"),
ColorUtils.colorBold("-psk", "green")));
sb.append(StringUtils.lineSeparator());
System.out.format(sb.toString());
sb.append(bundle.getString("nb.operation.add.desc")).append(StringUtils.lineSeparator());
sb.append(StringUtils.lineSeparator());
sb.append("Options:").append(StringUtils.lineSeparator());
sb.append(String.format("%s %s",
ColorUtils.colorBold("-imei ", "green"),
bundle.getString("nb.cmd.imei.desc")))
.append(StringUtils.lineSeparator());
sb.append(String.format("%s %s",
ColorUtils.colorBold("-name ", "green"),
bundle.getString("nb.cmd.name.desc")))
.append(StringUtils.lineSeparator());
sb.append(String.format("%s %s",
ColorUtils.colorBold("-obsv ", "green"),
bundle.getString("nb.cmd.obsv.desc")))
.append(StringUtils.lineSeparator());
sb.append(String.format("%s %s",
ColorUtils.colorBold("-imsi ", "green"),
bundle.getString("nb.cmd.imsi.desc")))
.append(StringUtils.lineSeparator());
sb.append(String.format("%s %s",
ColorUtils.colorBold("-psk ", "green"),
bundle.getString("nb.cmd.psk.desc")))
.append(StringUtils.lineSeparator());
System.out.print(sb);
break;
case "update":
sb.append(ColorUtils.cyanAnnotation("update: " + bundle.getString("nb.operation.update.desc")))
.append(StringUtils.lineSeparator());
sb.append(" usage: update imei name").append(StringUtils.lineSeparator());
sb.append(ColorUtils.colorBold("Usage: ", "black")
+ String.format("> %s %s <imei> [%s <name>]",
ColorUtils.colorBold("update", "green"),
ColorUtils.colorBold("-imei", "green"),
ColorUtils.colorBold("-name", "green")));
sb.append(StringUtils.lineSeparator());
sb.append(bundle.getString("nb.operation.update.desc")).append(StringUtils.lineSeparator());
sb.append(StringUtils.lineSeparator());
System.out.format(sb.toString());
sb.append("Options:").append(StringUtils.lineSeparator());
sb.append(String.format("%s %s",
ColorUtils.colorBold("-imei ", "green"),
bundle.getString("nb.cmd.imei.desc")))
.append(StringUtils.lineSeparator());
sb.append(String.format("%s %s",
ColorUtils.colorBold("-name ", "green"),
bundle.getString("nb.cmd.name.desc")))
.append(StringUtils.lineSeparator());
System.out.print(sb);
break;
case "del":
sb.append(ColorUtils.cyanAnnotation("del: " + bundle.getString("nb.operation.del.desc")))
.append(StringUtils.lineSeparator());
sb.append(" usage: del imei").append(StringUtils.lineSeparator());
case "delete":
sb.append(ColorUtils.colorBold("Usage: ", "black")
+ String.format("> %s %s",
ColorUtils.colorBold("del,delete", "green"),
ColorUtils.colorBold("imei", "green")));
sb.append(StringUtils.lineSeparator());
System.out.format(sb.toString());
sb.append(bundle.getString("nb.operation.del.desc")).append(StringUtils.lineSeparator());
sb.append(StringUtils.lineSeparator());
System.out.print(sb);
break;
case "show":
sb.append(ColorUtils.cyanAnnotation("show: " + bundle.getString("nb.operation.get.desc")))
.append(StringUtils.lineSeparator());
sb.append(" usage: show imei").append(StringUtils.lineSeparator());
sb.append(ColorUtils.colorBold("Usage: ", "black")
+ String.format("> %s %s",
ColorUtils.colorBold("show", "green"),
ColorUtils.colorBold("imei", "green")));
sb.append(StringUtils.lineSeparator());
sb.append(bundle.getString("nb.operation.get.desc")).append(StringUtils.lineSeparator());
sb.append(StringUtils.lineSeparator());
System.out.format(sb.toString());
System.out.print(sb);
break;
case "log":
sb.append(ColorUtils.cyanAnnotation("log: " + bundle.getString("nb.operation.log.desc")))
sb.append(ColorUtils.colorBold("Usage: ", "black")
+ String.format("> %s %s <imei> [%s <name>] [%s <startTime>] [%s <endTime>]",
ColorUtils.colorBold("log", "green"),
ColorUtils.colorBold("-imei", "green"),
ColorUtils.colorBold("-limit", "green"),
ColorUtils.colorBold("-startTime", "green"),
ColorUtils.colorBold("-endTime", "green")));
sb.append(StringUtils.lineSeparator());
sb.append(bundle.getString("nb.operation.log.desc")).append(StringUtils.lineSeparator());
sb.append(StringUtils.lineSeparator());
sb.append("Options:").append(StringUtils.lineSeparator());

sb.append(String.format("%s %s",
ColorUtils.colorBold("-imei ", "green"),
bundle.getString("nb.cmd.imei.desc")))
.append(StringUtils.lineSeparator());
sb.append(String.format("%s %s",
ColorUtils.colorBold("-limit ", "green"),
bundle.getString("nb.cmd.limit.desc")))
.append(StringUtils.lineSeparator());
sb.append(" usage: time format:2019-02-01T00:01:01").append(StringUtils.lineSeparator());
sb.append(" - log imei : 50 of data reported by the device today").append(StringUtils.lineSeparator());
sb.append(" - log imei limit : limit of data reported by the device today").append(StringUtils.lineSeparator());
sb.append(" - log imei startTime endTime : 50 of data reported by the device from startTime to endTime" )
sb.append(String.format("%s %s",
ColorUtils.colorBold("-startTime ", "green"),
bundle.getString("nb.cmd.startTime.desc")))
.append(StringUtils.lineSeparator());
sb.append(" - log imei startTime endTime limit : limit of data reported by the device from startTime to endTime" )
sb.append(String.format("%s %s",
ColorUtils.colorBold("-endTime ", "green"),
bundle.getString("nb.cmd.endTime.desc")))
.append(StringUtils.lineSeparator());
System.out.format(sb.toString());
System.out.print(sb);
break;
case "command":
sb.append(ColorUtils.cyanAnnotation("command: " + bundle.getString("nb.operation.command.desc")))
case "cmd":
sb.append(ColorUtils.colorBold("Usage: ", "black")
+ String.format("> %s %s <imei> [%s <startTime>] [%s <endTime>] [%s <pageNo>] [%s <pageSize>]",
ColorUtils.colorBold("cmd,command", "green"),
ColorUtils.colorBold("-imei", "green"),
ColorUtils.colorBold("-startTime", "green"),
ColorUtils.colorBold("-endTime", "green"),
ColorUtils.colorBold("-pn", "green"),
ColorUtils.colorBold("-ps", "green")));
sb.append(StringUtils.lineSeparator());
sb.append(bundle.getString("nb.operation.command.desc")).append(StringUtils.lineSeparator());
sb.append(StringUtils.lineSeparator());
sb.append("Options:").append(StringUtils.lineSeparator());
sb.append(String.format("%s %s",
ColorUtils.colorBold("-imei ", "green"),
bundle.getString("nb.cmd.sv.desc")))
.append(StringUtils.lineSeparator());
sb.append(String.format("%s %s",
ColorUtils.colorBold("-startTime ", "green"),
bundle.getString("nb.cmd.startTime.desc")))
.append(StringUtils.lineSeparator());
sb.append(String.format("%s %s",
ColorUtils.colorBold("-endTime ", "green"),
bundle.getString("nb.cmd.endTime.desc")))
.append(StringUtils.lineSeparator());
sb.append(" usage: time format:2019-02-01T00:01:01").append(StringUtils.lineSeparator());
sb.append(" - command imei : print first page delivery command of the device").append(StringUtils.lineSeparator());
sb.append(" - command imei pageNo : print pageNo delivery command of the device").append(StringUtils.lineSeparator());
sb.append(" - command imei start pageNo : print pageNo delivery command of the device from startTime").append(StringUtils.lineSeparator());
System.out.format(sb.toString());
sb.append(String.format("%s %s",
ColorUtils.colorBold("-pn --pageNo ", "green"),
bundle.getString("nb.cmd.pn.desc")))
.append(StringUtils.lineSeparator());
sb.append(String.format("%s %s",
ColorUtils.colorBold("-ps --pageSize ", "green"),
bundle.getString("nb.cmd.ps.desc")))
.append(StringUtils.lineSeparator());
System.out.print(sb);
break;
default:
break;

}
}

public void printAllHelpInfo() {
StringBuilder sb = new StringBuilder();
sb.append("").append(StringUtils.lineSeparator());
sb.append(ColorUtils.colorBold("Usage:", "black") + ColorUtils.colorBold(" > ", "green")
+ "{ add | del | update | show | list | log | command | exit }").append(StringUtils.lineSeparator());
sb.append("").append(StringUtils.lineSeparator());
sb.append(bundle.getString("nb.shellmode.help")).append(StringUtils.lineSeparator());
sb.append("").append(StringUtils.lineSeparator());
sb.append(ColorUtils.colorBold(bundle.getString("general.commands"), "black"))
.append(StringUtils.lineSeparator());
sb.append(ColorUtils.colorBold(" help ", "green")).append(bundle.getString("general.subCommand.help")).append(StringUtils.lineSeparator());
sb.append(ColorUtils.colorBold(" add ", "green")).append(bundle.getString("nb.operation.add.desc")).append(StringUtils.lineSeparator());
sb.append(ColorUtils.colorBold(" del, delete ", "green")).append(bundle.getString("nb.operation.del.desc")).append(StringUtils.lineSeparator());
sb.append(ColorUtils.colorBold(" update ", "green")).append(bundle.getString("nb.operation.update.desc")).append(StringUtils.lineSeparator());
sb.append(ColorUtils.colorBold(" show ", "green")).append(bundle.getString("nb.operation.get.desc")).append(StringUtils.lineSeparator());
sb.append(ColorUtils.colorBold(" ls, list ", "green")).append(bundle.getString("nb.operation.list.desc")).append(StringUtils.lineSeparator());
sb.append(ColorUtils.colorBold(" log ", "green")).append(bundle.getString("nb.operation.log.desc")).append(StringUtils.lineSeparator());
sb.append(ColorUtils.colorBold(" command ", "green")).append(bundle.getString("nb.operation.command.desc")).append(StringUtils.lineSeparator());
System.out.println(sb);
}
}
Loading

0 comments on commit 28b220d

Please sign in to comment.