File tree Expand file tree Collapse file tree 7 files changed +36
-8
lines changed
toolkit-common/src/main/java/iot/technology/client/toolkit/common/utils
toolkit-mqtt/src/main/java/iot/technology/client/toolkit/mqtt/command/sub
toolkit-nbiot/src/main/java/iot/technology/client/toolkit/nb Expand file tree Collapse file tree 7 files changed +36
-8
lines changed Original file line number Diff line number Diff line change 1515 */
1616package iot .technology .client .toolkit .common .utils ;
1717
18+ import iot .technology .client .toolkit .common .constants .StorageConstants ;
19+
1820/**
1921 * @author mushuwei
2022 */
@@ -26,6 +28,13 @@ public static String lineSeparator() {
2628 return lineSeparator ;
2729 }
2830
31+ public static void toolkitPromptText () {
32+ StringBuilder sb = new StringBuilder ();
33+ sb .append ("Welcome to Toolkit " ).append (StorageConstants .TOOLKIT_VERSION ).append (StringUtils .lineSeparator );
34+ sb .append ("Press Ctrl+C or `exit` to exit the REPL" );
35+ System .out .println (sb );
36+ }
37+
2938 public static boolean hasText (String str ) {
3039 return (str != null && !str .isEmpty () && containsText (str ));
3140 }
Original file line number Diff line number Diff line change 2222import iot .technology .client .toolkit .common .rule .TkNode ;
2323import iot .technology .client .toolkit .common .utils .FileUtils ;
2424import iot .technology .client .toolkit .common .utils .ObjectUtils ;
25+ import iot .technology .client .toolkit .common .utils .StringUtils ;
2526import iot .technology .client .toolkit .mqtt .service .MqttBizService ;
2627import iot .technology .client .toolkit .mqtt .service .MqttSettingsRuleChainProcessor ;
2728import iot .technology .client .toolkit .mqtt .service .domain .MqttConfigSettingsDomain ;
@@ -79,7 +80,7 @@ public Integer call() throws Exception {
7980 context .setPromptData (isNew ? null : bizService .getMqttConfigList ());
8081
8182 String code = isNew ? ruleChain .getRootPublishNewConfigNode () : ruleChain .getRootPublishSelectConfigNode ();
82-
83+ StringUtils . toolkitPromptText ();
8384 while (true ) {
8485 String data ;
8586 try {
@@ -91,6 +92,9 @@ public Integer call() throws Exception {
9192 tkNode .prePrompt (context );
9293 data = reader .readLine (tkNode .nodePrompt ());
9394 context .setData (data );
95+ if (data .equals ("exit" )) {
96+ break ;
97+ }
9498 tkNode .check (context );
9599 String codeData = tkNode .getValue (context );
96100 bizService .printValueToConsole (code , codeData , context );
Original file line number Diff line number Diff line change 2020import iot .technology .client .toolkit .common .constants .StorageConstants ;
2121import iot .technology .client .toolkit .common .rule .ProcessContext ;
2222import iot .technology .client .toolkit .common .rule .TkProcessor ;
23+ import iot .technology .client .toolkit .common .utils .StringUtils ;
2324import iot .technology .client .toolkit .mqtt .service .processor .*;
2425import org .jline .reader .*;
2526import org .jline .reader .impl .DefaultParser ;
@@ -90,12 +91,16 @@ public Integer call() throws Exception {
9091 .build ();
9192
9293 String prompt = bundle .getString ("mqtt.settings.command.prompt" ) + GlobalConstants .promptSeparator ;
94+ StringUtils .toolkitPromptText ();
9395 while (true ) {
9496 String data ;
9597 try {
9698 data = reader .readLine (prompt );
9799 ProcessContext context = new ProcessContext ();
98100 context .setData (data );
101+ if (data .equals ("exit" )) {
102+ break ;
103+ }
99104 for (TkProcessor processor : getTkProcessorList ()) {
100105 if (processor .supports (context )) {
101106 processor .handle (context );
@@ -105,5 +110,6 @@ public Integer call() throws Exception {
105110 return ExitCodeEnum .ERROR .getValue ();
106111 }
107112 }
113+ return ExitCodeEnum .SUCCESS .getValue ();
108114 }
109115}
Original file line number Diff line number Diff line change 2222import iot .technology .client .toolkit .common .rule .TkNode ;
2323import iot .technology .client .toolkit .common .utils .FileUtils ;
2424import iot .technology .client .toolkit .common .utils .ObjectUtils ;
25+ import iot .technology .client .toolkit .common .utils .StringUtils ;
2526import iot .technology .client .toolkit .mqtt .service .MqttBizService ;
2627import iot .technology .client .toolkit .mqtt .service .MqttSettingsRuleChainProcessor ;
2728import iot .technology .client .toolkit .mqtt .service .domain .MqttConfigSettingsDomain ;
@@ -79,7 +80,7 @@ public Integer call() throws Exception {
7980 context .setPromptData (isNew ? null : bizService .getMqttConfigList ());
8081
8182 String code = isNew ? ruleChain .getRootPublishNewConfigNode () : ruleChain .getRootPublishSelectConfigNode ();
82-
83+ StringUtils . toolkitPromptText ();
8384 while (true ) {
8485 String data ;
8586 try {
@@ -91,6 +92,9 @@ public Integer call() throws Exception {
9192 tkNode .prePrompt (context );
9293 data = reader .readLine (tkNode .nodePrompt ());
9394 context .setData (data );
95+ if (data .equals ("exit" )) {
96+ break ;
97+ }
9498 tkNode .check (context );
9599 bizService .printValueToConsole (code , tkNode .getValue (context ), context );
96100 ObjectUtils .setValue (domain , code , tkNode .getValue (context ));
Original file line number Diff line number Diff line change 1919import iot .technology .client .toolkit .common .rule .NodeContext ;
2020import iot .technology .client .toolkit .common .rule .TkNode ;
2121import iot .technology .client .toolkit .common .utils .ObjectUtils ;
22+ import iot .technology .client .toolkit .common .utils .StringUtils ;
2223import iot .technology .client .toolkit .nb .service .NbBizService ;
2324import iot .technology .client .toolkit .nb .service .NbConfigSettingsDomain ;
2425import iot .technology .client .toolkit .nb .service .NbRuleChainProcessor ;
@@ -64,7 +65,7 @@ public Integer call() throws Exception {
6465 NodeContext context = new NodeContext ();
6566 NbConfigSettingsDomain domain = new NbConfigSettingsDomain ();
6667 String code = ruleChain .getNbTypeNode ();
67-
68+ StringUtils . toolkitPromptText ();
6869 while (true ) {
6970 try {
7071 String node = processor .get (code );
@@ -75,6 +76,9 @@ public Integer call() throws Exception {
7576 tkNode .prePrompt (context );
7677 String data = reader .readLine (tkNode .nodePrompt ());
7778 context .setData (data );
79+ if (data .equals ("exit" )) {
80+ break ;
81+ }
7882 tkNode .check (context );
7983 bizService .printValueToConsole (code , context );
8084 ObjectUtils .setValue (domain , code , tkNode .getValue (context ));
Original file line number Diff line number Diff line change 2121import iot .technology .client .toolkit .common .rule .TkNode ;
2222import iot .technology .client .toolkit .common .rule .TkProcessor ;
2323import iot .technology .client .toolkit .common .utils .ObjectUtils ;
24+ import iot .technology .client .toolkit .common .utils .StringUtils ;
2425import iot .technology .client .toolkit .nb .service .NbBizService ;
2526import iot .technology .client .toolkit .nb .service .NbConfigSettingsDomain ;
2627import iot .technology .client .toolkit .nb .service .NbRuleChainProcessor ;
@@ -93,7 +94,7 @@ public Integer call() throws Exception {
9394 context .setType ("settings" );
9495 NbConfigSettingsDomain domain = new NbConfigSettingsDomain ();
9596 String code = ruleChain .getNbTypeNode ();
96-
97+ StringUtils . toolkitPromptText ();
9798 while (true ) {
9899 boolean isNbSettings = code .equals (NbSettingsCodeEnum .NB_SETTINGS .getCode ());
99100 LineReader reader = isNbSettings ?
@@ -116,6 +117,9 @@ public Integer call() throws Exception {
116117 tkNode .prePrompt (context );
117118 String data = reader .readLine (tkNode .nodePrompt ());
118119 context .setData (data );
120+ if (data .equals ("exit" )) {
121+ break ;
122+ }
119123 if (isNbSettings ) {
120124 NbSettingsContext nbSettingsContext = new NbSettingsContext ();
121125 nbSettingsContext .setNbType (domain .getNbType ());
Original file line number Diff line number Diff line change @@ -21,10 +21,7 @@ public class NbTypeNode implements TkNode {
2121
2222 @ Override
2323 public void prePrompt (NodeContext context ) {
24- StringBuilder sb = new StringBuilder ();
25- sb .append ("Welcome to Toolkit " ).append (StorageConstants .TOOLKIT_VERSION ).append (StringUtils .lineSeparator );
26- sb .append (StringUtils .lineSeparator ());
27-
24+ StringUtils .toolkitPromptText ();
2825 if (bundle .getLocale ().equals (Locale .CHINESE )) {
2926 System .out .format (ColorUtils .greenItalic ("(1) 电信AEP * " ) + "%n" );
3027 System .out .format (ColorUtils .greenItalic ("(2) 移动OneNET" ) + "%n" );
You can’t perform that action at this time.
0 commit comments