Fossil SCM
Fixed Ctrl-D handling in rhino-based shell.
Commit
15c6caf29ece4354b90ffd1325ad02e6500b8b7d
Parent
e21b391dcd355a9…
1 file changed
+22
-3
+22
-3
| --- ajax/i-test/rhino-shell.js | ||
| +++ ajax/i-test/rhino-shell.js | ||
| @@ -107,11 +107,12 @@ | ||
| 107 | 107 | importPackage(java.lang); |
| 108 | 108 | var stdin = new BufferedReader(new InputStreamReader(System['in'])); |
| 109 | 109 | var self = this; |
| 110 | 110 | return function(prompt) { |
| 111 | 111 | if(prompt) print(prompt); |
| 112 | - return String(stdin.readLine()); | |
| 112 | + var x = stdin.readLine(); | |
| 113 | + return null===x ? x : String(x) /*convert to JS string!*/; | |
| 113 | 114 | }; |
| 114 | 115 | }()); |
| 115 | 116 | |
| 116 | 117 | FShell.dispatchLine = function(line){ |
| 117 | 118 | var av = line.split(' '); // FIXME: to shell-like tokenization. Too tired! |
| @@ -141,19 +142,28 @@ | ||
| 141 | 142 | callback(resp,req); |
| 142 | 143 | } |
| 143 | 144 | }; |
| 144 | 145 | }; |
| 145 | 146 | FShell.commandHandlers = { |
| 147 | + "?":function(args){ | |
| 148 | + var k; | |
| 149 | + print("Available commands...\n"); | |
| 150 | + var o = FShell.commandHandlers; | |
| 151 | + for(k in o){ | |
| 152 | + if(! o.hasOwnProperty(k)) continue; | |
| 153 | + print("\t"+k); | |
| 154 | + } | |
| 155 | + }, | |
| 146 | 156 | "/":function(args){ |
| 147 | 157 | FShell.fossil.sendCommand('/json'+args[0],undefined,{ |
| 148 | 158 | beforeSend:function(req,opt){ |
| 149 | 159 | print("Sending to: "+opt.url); |
| 150 | 160 | }, |
| 151 | 161 | onResponse:FShell.onResponseDefault() |
| 152 | 162 | }); |
| 153 | 163 | }, |
| 154 | - "e":function(args){ | |
| 164 | + "eval":function(args){ | |
| 155 | 165 | eval(args.join(' ')); |
| 156 | 166 | }, |
| 157 | 167 | "login":function(args){ |
| 158 | 168 | FShell.fossil.login(args[1], args[2], { |
| 159 | 169 | onResponse:FShell.onResponseDefault() |
| @@ -167,10 +177,11 @@ | ||
| 167 | 177 | "HAI":function(args){ |
| 168 | 178 | FShell.fossil.HAI({ |
| 169 | 179 | onResponse:FShell.onResponseDefault() |
| 170 | 180 | }); |
| 171 | 181 | } |
| 182 | + | |
| 172 | 183 | }; |
| 173 | 184 | FShell.commandAliases = { |
| 174 | 185 | "li":"login", |
| 175 | 186 | "lo":"logout", |
| 176 | 187 | "who":"whoami", |
| @@ -177,13 +188,21 @@ | ||
| 177 | 188 | "hi":"HAI", |
| 178 | 189 | "tci":"/timeline/ci?limit=3" |
| 179 | 190 | }; |
| 180 | 191 | FShell.mainLoop = function(){ |
| 181 | 192 | var line; |
| 182 | - while( null != (line = this.readline(this.prompt)) ){ | |
| 193 | + var check = /\S/; | |
| 194 | + //var isJavaNull = /java\.lang\.null/; | |
| 195 | + //print(typeof java.lang['null']); | |
| 196 | + while( null != (line=this.readline(this.prompt)) ){ | |
| 197 | + if(null===line) break /*EOF*/; | |
| 198 | + else if( "" === line ) continue; | |
| 183 | 199 | //print("Got line: "+line); |
| 200 | + else if(!check.test(line)) continue; | |
| 201 | + print('typeof line = '+typeof line); | |
| 184 | 202 | this.dispatchLine(line); |
| 185 | 203 | print(""); |
| 186 | 204 | } |
| 205 | + print("Bye!"); | |
| 187 | 206 | }; |
| 188 | 207 | |
| 189 | 208 | FShell.mainLoop(); |
| 190 | 209 |
| --- ajax/i-test/rhino-shell.js | |
| +++ ajax/i-test/rhino-shell.js | |
| @@ -107,11 +107,12 @@ | |
| 107 | importPackage(java.lang); |
| 108 | var stdin = new BufferedReader(new InputStreamReader(System['in'])); |
| 109 | var self = this; |
| 110 | return function(prompt) { |
| 111 | if(prompt) print(prompt); |
| 112 | return String(stdin.readLine()); |
| 113 | }; |
| 114 | }()); |
| 115 | |
| 116 | FShell.dispatchLine = function(line){ |
| 117 | var av = line.split(' '); // FIXME: to shell-like tokenization. Too tired! |
| @@ -141,19 +142,28 @@ | |
| 141 | callback(resp,req); |
| 142 | } |
| 143 | }; |
| 144 | }; |
| 145 | FShell.commandHandlers = { |
| 146 | "/":function(args){ |
| 147 | FShell.fossil.sendCommand('/json'+args[0],undefined,{ |
| 148 | beforeSend:function(req,opt){ |
| 149 | print("Sending to: "+opt.url); |
| 150 | }, |
| 151 | onResponse:FShell.onResponseDefault() |
| 152 | }); |
| 153 | }, |
| 154 | "e":function(args){ |
| 155 | eval(args.join(' ')); |
| 156 | }, |
| 157 | "login":function(args){ |
| 158 | FShell.fossil.login(args[1], args[2], { |
| 159 | onResponse:FShell.onResponseDefault() |
| @@ -167,10 +177,11 @@ | |
| 167 | "HAI":function(args){ |
| 168 | FShell.fossil.HAI({ |
| 169 | onResponse:FShell.onResponseDefault() |
| 170 | }); |
| 171 | } |
| 172 | }; |
| 173 | FShell.commandAliases = { |
| 174 | "li":"login", |
| 175 | "lo":"logout", |
| 176 | "who":"whoami", |
| @@ -177,13 +188,21 @@ | |
| 177 | "hi":"HAI", |
| 178 | "tci":"/timeline/ci?limit=3" |
| 179 | }; |
| 180 | FShell.mainLoop = function(){ |
| 181 | var line; |
| 182 | while( null != (line = this.readline(this.prompt)) ){ |
| 183 | //print("Got line: "+line); |
| 184 | this.dispatchLine(line); |
| 185 | print(""); |
| 186 | } |
| 187 | }; |
| 188 | |
| 189 | FShell.mainLoop(); |
| 190 |
| --- ajax/i-test/rhino-shell.js | |
| +++ ajax/i-test/rhino-shell.js | |
| @@ -107,11 +107,12 @@ | |
| 107 | importPackage(java.lang); |
| 108 | var stdin = new BufferedReader(new InputStreamReader(System['in'])); |
| 109 | var self = this; |
| 110 | return function(prompt) { |
| 111 | if(prompt) print(prompt); |
| 112 | var x = stdin.readLine(); |
| 113 | return null===x ? x : String(x) /*convert to JS string!*/; |
| 114 | }; |
| 115 | }()); |
| 116 | |
| 117 | FShell.dispatchLine = function(line){ |
| 118 | var av = line.split(' '); // FIXME: to shell-like tokenization. Too tired! |
| @@ -141,19 +142,28 @@ | |
| 142 | callback(resp,req); |
| 143 | } |
| 144 | }; |
| 145 | }; |
| 146 | FShell.commandHandlers = { |
| 147 | "?":function(args){ |
| 148 | var k; |
| 149 | print("Available commands...\n"); |
| 150 | var o = FShell.commandHandlers; |
| 151 | for(k in o){ |
| 152 | if(! o.hasOwnProperty(k)) continue; |
| 153 | print("\t"+k); |
| 154 | } |
| 155 | }, |
| 156 | "/":function(args){ |
| 157 | FShell.fossil.sendCommand('/json'+args[0],undefined,{ |
| 158 | beforeSend:function(req,opt){ |
| 159 | print("Sending to: "+opt.url); |
| 160 | }, |
| 161 | onResponse:FShell.onResponseDefault() |
| 162 | }); |
| 163 | }, |
| 164 | "eval":function(args){ |
| 165 | eval(args.join(' ')); |
| 166 | }, |
| 167 | "login":function(args){ |
| 168 | FShell.fossil.login(args[1], args[2], { |
| 169 | onResponse:FShell.onResponseDefault() |
| @@ -167,10 +177,11 @@ | |
| 177 | "HAI":function(args){ |
| 178 | FShell.fossil.HAI({ |
| 179 | onResponse:FShell.onResponseDefault() |
| 180 | }); |
| 181 | } |
| 182 | |
| 183 | }; |
| 184 | FShell.commandAliases = { |
| 185 | "li":"login", |
| 186 | "lo":"logout", |
| 187 | "who":"whoami", |
| @@ -177,13 +188,21 @@ | |
| 188 | "hi":"HAI", |
| 189 | "tci":"/timeline/ci?limit=3" |
| 190 | }; |
| 191 | FShell.mainLoop = function(){ |
| 192 | var line; |
| 193 | var check = /\S/; |
| 194 | //var isJavaNull = /java\.lang\.null/; |
| 195 | //print(typeof java.lang['null']); |
| 196 | while( null != (line=this.readline(this.prompt)) ){ |
| 197 | if(null===line) break /*EOF*/; |
| 198 | else if( "" === line ) continue; |
| 199 | //print("Got line: "+line); |
| 200 | else if(!check.test(line)) continue; |
| 201 | print('typeof line = '+typeof line); |
| 202 | this.dispatchLine(line); |
| 203 | print(""); |
| 204 | } |
| 205 | print("Bye!"); |
| 206 | }; |
| 207 | |
| 208 | FShell.mainLoop(); |
| 209 |