File tree Expand file tree Collapse file tree
FastChatProtocolInterface Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -177,6 +177,7 @@ private static void PrintHelp()
177177 Console . WriteLine ( "fachpi 通常のサーバーを起動する。如何なる拡張機能も使用しない事を強制する。" ) ;
178178 Console . WriteLine ( "sifosc SIFOSC 機能を有効にしてサーバーを起動する。" ) ;
179179 Console . WriteLine ( "client クライアントを起動する。" ) ;
180+ Console . WriteLine ( "repl サーバーを起動せずに SIFOSC を実行する。" ) ;
180181 Console . WriteLine ( ) ;
181182 Console . WriteLine ( "注意:幾つかのオプションにはこの説明書に記載されていない別表記があります。" ) ;
182183 Console . WriteLine ( ) ;
Original file line number Diff line number Diff line change 55 * distributed under the MIT License.
66****/
77
8+ using System ;
89using System . Collections . Concurrent ;
910using System . Net ;
1011using System . Threading ;
@@ -26,6 +27,7 @@ static ExecutionMode()
2627 _modes . TryAdd ( "fachpi" , ServerImpl . _inst_fachpi ) ;
2728 _modes . TryAdd ( "sifosc" , ServerImpl . _inst_sifosc ) ;
2829 _modes . TryAdd ( "client" , ClientImpl . _inst ) ;
30+ _modes . TryAdd ( "repl" , ReplImpl . _inst ) ;
2931 }
3032
3133 public static ExecutionMode ? GetMode ( string name )
@@ -79,5 +81,29 @@ public override void Run(in CommandLineArguments args)
7981 client . Connect ( args . HostName , args . Port ) ;
8082 }
8183 }
84+
85+ private sealed class ReplImpl : ExecutionMode
86+ {
87+ internal static readonly ReplImpl _inst = new ( ) ;
88+
89+ private ReplImpl ( ) { }
90+
91+ public override void Run ( in CommandLineArguments args )
92+ {
93+ Console . WriteLine ( "SIFOSC を実行できます。" ) ;
94+
95+ while ( true ) {
96+ Console . Write ( "> " ) ;
97+
98+ string ? input = Console . ReadLine ( ) ;
99+ if ( ! string . IsNullOrEmpty ( input ) ) {
100+ string output = SifoscServer . RunScriptLine ( input ) ;
101+
102+ Console . WriteLine ( output ) ;
103+ Console . WriteLine ( ) ;
104+ }
105+ }
106+ }
107+ }
82108 }
83109}
Original file line number Diff line number Diff line change @@ -21,8 +21,11 @@ public override void OnConnected()
2121 }
2222
2323 protected override string ReceiveMessageCore ( FachpiCommunicationFlow flow )
24+ => RunScriptLine ( flow . Reader . ReadString ( ) ) ;
25+
26+ public static string RunScriptLine ( string s )
2427 {
25- var sc = new SourceCode ( flow . Reader . ReadString ( ) ) ;
28+ var sc = new SourceCode ( s ) ;
2629 if ( sc . TryParseValue ( out var result ) ) {
2730 return result . ToString ( ) ;
2831 } else {
You can’t perform that action at this time.
0 commit comments