Skip to content

Commit df2a2c9

Browse files
committed
fix System terminal on Windows: "Unable to create a system terminal, creating a dumb terminal (enable debug logging for more information)"
1 parent 9afec56 commit df2a2c9

File tree

2 files changed

+46
-9
lines changed

2 files changed

+46
-9
lines changed

toolkit-nbiot/src/main/java/iot/technology/client/toolkit/nb/service/processor/MobileBizService.java

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@
1919
import iot.technology.client.toolkit.common.rule.TkProcessor;
2020
import iot.technology.client.toolkit.nb.service.mobile.domain.MobileConfigDomain;
2121
import iot.technology.client.toolkit.nb.service.processor.mobile.*;
22-
import org.jline.reader.LineReader;
23-
import org.jline.reader.LineReaderBuilder;
22+
import org.jline.reader.*;
2423
import org.jline.reader.impl.DefaultParser;
24+
import org.jline.reader.impl.completer.AggregateCompleter;
25+
import org.jline.reader.impl.completer.ArgumentCompleter;
26+
import org.jline.reader.impl.completer.NullCompleter;
27+
import org.jline.reader.impl.completer.StringsCompleter;
2528
import org.jline.terminal.Terminal;
2629

2730
import java.util.ArrayList;
@@ -43,10 +46,26 @@ public final List<TkProcessor> getTkProcessorList() {
4346
return tkProcessorList;
4447
}
4548

49+
Completer listCompleter = new ArgumentCompleter(new StringsCompleter("list"), NullCompleter.INSTANCE);
50+
51+
Completer showCompleter = new ArgumentCompleter(new StringsCompleter("show"), NullCompleter.INSTANCE);
52+
53+
Completer delCompleter = new ArgumentCompleter(new StringsCompleter("del"), NullCompleter.INSTANCE);
54+
55+
Completer addCompleter = new ArgumentCompleter(new StringsCompleter("add"), NullCompleter.INSTANCE);
56+
57+
Completer updateCompleter = new ArgumentCompleter(new StringsCompleter("update"), NullCompleter.INSTANCE);
58+
59+
Completer helpCompleter = new ArgumentCompleter(new StringsCompleter("help"), NullCompleter.INSTANCE);
60+
61+
Completer nbMobileCompleter =
62+
new AggregateCompleter(listCompleter, showCompleter, delCompleter, addCompleter, helpCompleter, updateCompleter);
63+
4664
public boolean call(MobileConfigDomain mobileConfigDomain, Terminal terminal) {
4765
try {
4866
LineReader reader = LineReaderBuilder.builder()
4967
.terminal(terminal)
68+
.completer(nbMobileCompleter)
5069
.parser(new DefaultParser())
5170
.build();
5271

@@ -67,8 +86,8 @@ public boolean call(MobileConfigDomain mobileConfigDomain, Terminal terminal) {
6786
}
6887
}
6988
}
70-
} catch (Exception e) {
71-
throw new RuntimeException(e);
89+
} catch (UserInterruptException | EndOfFileException e) {
90+
return false;
7291
}
7392
return true;
7493
}

toolkit-nbiot/src/main/java/iot/technology/client/toolkit/nb/service/processor/TelecomBizService.java

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@
1515
*/
1616
package iot.technology.client.toolkit.nb.service.processor;
1717

18-
1918
import iot.technology.client.toolkit.common.constants.GlobalConstants;
2019
import iot.technology.client.toolkit.common.rule.TkProcessor;
2120
import iot.technology.client.toolkit.nb.service.processor.telecom.*;
2221
import iot.technology.client.toolkit.nb.service.telecom.domain.TelecomConfigDomain;
23-
import org.jline.reader.LineReader;
24-
import org.jline.reader.LineReaderBuilder;
22+
import org.jline.reader.*;
2523
import org.jline.reader.impl.DefaultParser;
24+
import org.jline.reader.impl.completer.AggregateCompleter;
25+
import org.jline.reader.impl.completer.ArgumentCompleter;
26+
import org.jline.reader.impl.completer.NullCompleter;
27+
import org.jline.reader.impl.completer.StringsCompleter;
2628
import org.jline.terminal.Terminal;
2729

2830
import java.util.ArrayList;
@@ -44,10 +46,26 @@ public final List<TkProcessor> getTkProcessorList() {
4446
return tkProcessorList;
4547
}
4648

49+
Completer listCompleter = new ArgumentCompleter(new StringsCompleter("list"), NullCompleter.INSTANCE);
50+
51+
Completer showCompleter = new ArgumentCompleter(new StringsCompleter("show"), NullCompleter.INSTANCE);
52+
53+
Completer delCompleter = new ArgumentCompleter(new StringsCompleter("del"), NullCompleter.INSTANCE);
54+
55+
Completer addCompleter = new ArgumentCompleter(new StringsCompleter("add"), NullCompleter.INSTANCE);
56+
57+
Completer updateCompleter = new ArgumentCompleter(new StringsCompleter("update"), NullCompleter.INSTANCE);
58+
59+
Completer helpCompleter = new ArgumentCompleter(new StringsCompleter("help"), NullCompleter.INSTANCE);
60+
61+
Completer nbTelecomCompleter =
62+
new AggregateCompleter(listCompleter, showCompleter, delCompleter, addCompleter, helpCompleter, updateCompleter);
63+
4764
public boolean call(TelecomConfigDomain telecomConfigDomain, Terminal terminal) {
4865
try {
4966
LineReader reader = LineReaderBuilder.builder()
5067
.terminal(terminal)
68+
.completer(nbTelecomCompleter)
5169
.parser(new DefaultParser())
5270
.build();
5371

@@ -68,8 +86,8 @@ public boolean call(TelecomConfigDomain telecomConfigDomain, Terminal terminal)
6886
}
6987
}
7088
}
71-
} catch (Exception e) {
72-
throw new RuntimeException(e);
89+
} catch (UserInterruptException | EndOfFileException e) {
90+
return false;
7391
}
7492
return true;
7593
}

0 commit comments

Comments
 (0)