1515 */
1616package iot .technology .client .toolkit .nb .service .processor ;
1717
18-
1918import iot .technology .client .toolkit .common .constants .GlobalConstants ;
2019import iot .technology .client .toolkit .common .rule .TkProcessor ;
2120import iot .technology .client .toolkit .nb .service .processor .telecom .*;
2221import 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 .*;
2523import 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 ;
2628import org .jline .terminal .Terminal ;
2729
2830import 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