Fossil SCM
Added a very, very prototypic/pre-alphalpha demo fossil shell. Requires rhino JS.
Commit
7ab5d85487f230075bbb240f9c00f3833f276dc9
Parent
09e5fcd795ce5fe…
1 file changed
+158
+158
| --- a/ajax/i-test/rhino-shell.js | ||
| +++ b/ajax/i-test/rhino-shell.js | ||
| @@ -0,0 +1,158 @@ | ||
| 1 | +var FShell = { | |
| 2 | + serverUrl: | |
| 3 | + 'http://localhost:8080' | |
| 4 | + //'http://fjson/cgi-bin/fossil-json.cgi' | |
| 5 | + //'http://192.168.1.62:8080' | |
| 6 | + //'http://fossil.wanderinghorse.net/repos/fossil-json-java/index.cgi' | |
| 7 | + , | |
| 8 | + verbose:false, | |
| 9 | + prompt:"fossil shell > ", | |
| 10 | + wiki:{}, | |
| 11 | + consol:java.lang.System.console(), | |
| 12 | + v:function(msg){ | |
| 13 | + if(this.verbose){ | |
| 14 | + print("VERBOSE: "+msg); | |
| 15 | + } | |
| 16 | + } | |
| 17 | +}; | |
| 18 | +(function bootstrap() { | |
| 19 | + var srcdir = '../js/'; | |
| 20 | + var includes = [srcdir+'json2.js', | |
| 21 | + srcdir+'whajaj.js', | |
| 22 | + srcdir+'fossil-ajaj.js' | |
| 23 | + ]; | |
| 24 | + for( var i in includes ) { | |
| 25 | + load(includes[i]); | |
| 26 | + } | |
| 27 | + WhAjaj.Connector.prototype.sendImpl = WhAjaj.Connector.sendImpls.rhino; | |
| 28 | + FShell.fossil = new FossilAjaj({ | |
| 29 | + asynchronous:false, /* rhino-based impl doesn't support async. */ | |
| 30 | + timeout:10000, | |
| 31 | + url:FShell.serverUrl | |
| 32 | + }); | |
| 33 | + print("Server: "+FShell.serverUrl); | |
| 34 | + var cb = FShell.fossil.ajaj.callbacks; | |
| 35 | + cb.beforeSend = function(req,opt){ | |
| 36 | + if(!FShell.verbose) return; | |
| 37 | + print("SENDING REQUEST: AJAJ options="+JSON.stringify(opt)); | |
| 38 | + if(req) print("Request envelope="+WhAjaj.stringify(req)); | |
| 39 | + }; | |
| 40 | + cb.afterSend = function(req,opt){ | |
| 41 | + //if(!FShell.verbose) return; | |
| 42 | + //print("REQUEST RETURNED: opt="+JSON.stringify(opt)); | |
| 43 | + //if(req) print("Request="+WhAjaj.stringify(req)); | |
| 44 | + }; | |
| 45 | + cb.onError = function(req,opt){ | |
| 46 | + //if(!FShell.verbose) return; | |
| 47 | + print("ERROR: "+WhAjaj.stringify(opt)); | |
| 48 | + }; | |
| 49 | + cb.onResponse = function(resp,req){ | |
| 50 | + if(!FShell.verbose) return; | |
| 51 | + if(resp && resp.resultCode){ | |
| 52 | + print("Response contains error info: "+resp.resultCode+": "+resp.resultText); | |
| 53 | + } | |
| 54 | + print("GOT RESPONSE: "+(('string'===typeof resp) ? resp : WhAjaj.stringify(resp)))whoami }; | |
| 55 | + FShell.fossil.HAI({ | |
| 56 | + onResponse:functionreturn String(stdin.readLine()); value. | |
| 57 | +*/ | |
| 58 | +function assert(cond, descr){ | |
| 59 | + descr = descr || "Undescribed condition."; | |
| 60 | + if(!cond){ | |
| 61 | + throw new Error("Assertion failed: "+descr); | |
| 62 | + }else{ | |
| 63 | + //print("Assertion OK: "+descr); | |
| 64 | + } | |
| 65 | +} | |
| 66 | + | |
| 67 | +/** | |
| 68 | + Convenience form of FShell.fossil.sendCommand(command,payload,ajajOpt). | |
| 69 | +*/ | |
| 70 | +function send(command,payload, ajajOpt){ | |
| 71 | + FShell.fossil.sendCommand(command,payload,ajajOpt); | |
| 72 | +} | |
| 73 | + | |
| 74 | +/** | |
| 75 | + Asserts that resp is-a Object, resp.fossil is-a string, and | |
| 76 | + !resp.resultCode. | |
| 77 | +*/ | |
| 78 | +function assertResponseOK(resp){ | |
| 79 | + assert('object' === typeof resp,'Response is-a object.'); | |
| 80 | + assert( 'string' === typeof resp.fossil, 'Response contains fossil property.'); | |
| 81 | + assert( !resp.resultCode, 'resp.resultCode='+resp.resultCode); | |
| 82 | +} | |
| 83 | +/** | |
| 84 | + Asserts that resp is-a Object, resp.fossil is-a string, and | |
| 85 | + resp.resultCode is a truthy value. If expectCode is set then | |
| 86 | + it also asserts that (resp./":function(args){ | |
| 87 | + FShell.fossil.sendCommand('/json'+args[0],undefined,{ | |
| 88 | + beforeSend:function(req,opt){ | |
| 89 | + print("Sending to: "+opt.url); | |
| 90 | + }, | |
| 91 | + onResponse:FShell.onResponseDefault(":function(args){ | |
| 92 | + eval(args.join(' ')); | |
| 93 | + }, | |
| 94 | + "login":function(args){ | |
| 95 | + FShell.fossil.login(args[1], args[2], { | |
| 96 | + onResponse:FShell.onResponseDefault() | |
| 97 | + }); | |
| 98 | + }, | |
| 99 | + "whoami":function(args){ | |
| 100 | + FShell.fossil.whoami({ | |
| 101 | + onResponse:FShell.onResponseDefault() | |
| 102 | + }); | |
| 103 | + }, | |
| 104 | + "HAI":function(args){ | |
| 105 | + FShell.fossil.HAI({ | |
| 106 | + onResponse:FShell.onResponseD}; | |
| 107 | +FShell.commandAliases = { | |
| 108 | + "li":"login", | |
| 109 | + "lo":"logout", | |
| 110 | + "who":"whoami", | |
| 111 | + "hi":"HAI", | |
| 112 | + "tci":"/timeline/ci?limit=3" | |
| 113 | +}; | |
| 114 | +FShell.mainLoop = funof java.lang['null'] = this.readlin = '+typeof line); | |
| 115 | + ; | |
| 116 | + } | |
| 117 | + print("Bye!h = this.commandHandlers[var FShell = { | |
| 118 | + serverUrl: | |
| 119 | + 'http://localhost:8080' | |
| 120 | + //'http://fjson/cgi-bin/fossil-json.cgi' | |
| 121 | + //'http://192.168.1.62:8080' | |
| 122 | + //'http://fossil.wanderinghorse.net/repos/fossil-json-java/index.cgi' | |
| 123 | + , | |
| 124 | + verbose:false, | |
| 125 | + prompt:"fossil shell > ", | |
| 126 | + wiki:{}, | |
| 127 | + consol:java.lang.System.console(), | |
| 128 | + v:function(msg){ | |
| 129 | + if(this.verbose){ | |
| 130 | + print("VERBOSE: "+msg); | |
| 131 | + } | |
| 132 | + } | |
| 133 | +}; | |
| 134 | +(function bootstrap() { | |
| 135 | + var srcdir = '../js/'; | |
| 136 | + var includes = [srcdir+'json2.js', | |
| 137 | + srcdir+'whajaj.js', | |
| 138 | + srcdir+'fossil-ajaj.js' | |
| 139 | + ]; | |
| 140 | + for( var i in includes ) { | |
| 141 | + load(includes[i]); | |
| 142 | + } | |
| 143 | + WhAjaj.Connector.prototype.sendImpl = WhAjaj.Connector.sendImpls.rhino; | |
| 144 | + FShell.fossil = new FossilAjaj({ | |
| 145 | + asynchronous:false, /* rhino-based impl doesn't support async. */ | |
| 146 | + timeout:10000, | |
| 147 | + url:FShell.serverUrl | |
| 148 | + }); | |
| 149 | + print("Server: "+FShell.serverUrl); | |
| 150 | + var cb = FShell.fossil.ajaj.callbacks; | |
| 151 | + cb.beforeSend = function(req,opt){ | |
| 152 | + if(!FShell.verbose) return; | |
| 153 | + print("SENDING REQUEST: AJAJ options="+JSON.stringify(opt)); | |
| 154 | + if(req) print("Request envelope="+WhAjaj.stringify(req)); | |
| 155 | + }; | |
| 156 | + cb.afterSend = function(req,opt){ | |
| 157 | + //if(!FShell.verbose) return; | |
| 158 | + //prin |
| --- a/ajax/i-test/rhino-shell.js | |
| +++ b/ajax/i-test/rhino-shell.js | |
| @@ -0,0 +1,158 @@ | |
| --- a/ajax/i-test/rhino-shell.js | |
| +++ b/ajax/i-test/rhino-shell.js | |
| @@ -0,0 +1,158 @@ | |
| 1 | var FShell = { |
| 2 | serverUrl: |
| 3 | 'http://localhost:8080' |
| 4 | //'http://fjson/cgi-bin/fossil-json.cgi' |
| 5 | //'http://192.168.1.62:8080' |
| 6 | //'http://fossil.wanderinghorse.net/repos/fossil-json-java/index.cgi' |
| 7 | , |
| 8 | verbose:false, |
| 9 | prompt:"fossil shell > ", |
| 10 | wiki:{}, |
| 11 | consol:java.lang.System.console(), |
| 12 | v:function(msg){ |
| 13 | if(this.verbose){ |
| 14 | print("VERBOSE: "+msg); |
| 15 | } |
| 16 | } |
| 17 | }; |
| 18 | (function bootstrap() { |
| 19 | var srcdir = '../js/'; |
| 20 | var includes = [srcdir+'json2.js', |
| 21 | srcdir+'whajaj.js', |
| 22 | srcdir+'fossil-ajaj.js' |
| 23 | ]; |
| 24 | for( var i in includes ) { |
| 25 | load(includes[i]); |
| 26 | } |
| 27 | WhAjaj.Connector.prototype.sendImpl = WhAjaj.Connector.sendImpls.rhino; |
| 28 | FShell.fossil = new FossilAjaj({ |
| 29 | asynchronous:false, /* rhino-based impl doesn't support async. */ |
| 30 | timeout:10000, |
| 31 | url:FShell.serverUrl |
| 32 | }); |
| 33 | print("Server: "+FShell.serverUrl); |
| 34 | var cb = FShell.fossil.ajaj.callbacks; |
| 35 | cb.beforeSend = function(req,opt){ |
| 36 | if(!FShell.verbose) return; |
| 37 | print("SENDING REQUEST: AJAJ options="+JSON.stringify(opt)); |
| 38 | if(req) print("Request envelope="+WhAjaj.stringify(req)); |
| 39 | }; |
| 40 | cb.afterSend = function(req,opt){ |
| 41 | //if(!FShell.verbose) return; |
| 42 | //print("REQUEST RETURNED: opt="+JSON.stringify(opt)); |
| 43 | //if(req) print("Request="+WhAjaj.stringify(req)); |
| 44 | }; |
| 45 | cb.onError = function(req,opt){ |
| 46 | //if(!FShell.verbose) return; |
| 47 | print("ERROR: "+WhAjaj.stringify(opt)); |
| 48 | }; |
| 49 | cb.onResponse = function(resp,req){ |
| 50 | if(!FShell.verbose) return; |
| 51 | if(resp && resp.resultCode){ |
| 52 | print("Response contains error info: "+resp.resultCode+": "+resp.resultText); |
| 53 | } |
| 54 | print("GOT RESPONSE: "+(('string'===typeof resp) ? resp : WhAjaj.stringify(resp)))whoami }; |
| 55 | FShell.fossil.HAI({ |
| 56 | onResponse:functionreturn String(stdin.readLine()); value. |
| 57 | */ |
| 58 | function assert(cond, descr){ |
| 59 | descr = descr || "Undescribed condition."; |
| 60 | if(!cond){ |
| 61 | throw new Error("Assertion failed: "+descr); |
| 62 | }else{ |
| 63 | //print("Assertion OK: "+descr); |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | Convenience form of FShell.fossil.sendCommand(command,payload,ajajOpt). |
| 69 | */ |
| 70 | function send(command,payload, ajajOpt){ |
| 71 | FShell.fossil.sendCommand(command,payload,ajajOpt); |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | Asserts that resp is-a Object, resp.fossil is-a string, and |
| 76 | !resp.resultCode. |
| 77 | */ |
| 78 | function assertResponseOK(resp){ |
| 79 | assert('object' === typeof resp,'Response is-a object.'); |
| 80 | assert( 'string' === typeof resp.fossil, 'Response contains fossil property.'); |
| 81 | assert( !resp.resultCode, 'resp.resultCode='+resp.resultCode); |
| 82 | } |
| 83 | /** |
| 84 | Asserts that resp is-a Object, resp.fossil is-a string, and |
| 85 | resp.resultCode is a truthy value. If expectCode is set then |
| 86 | it also asserts that (resp./":function(args){ |
| 87 | FShell.fossil.sendCommand('/json'+args[0],undefined,{ |
| 88 | beforeSend:function(req,opt){ |
| 89 | print("Sending to: "+opt.url); |
| 90 | }, |
| 91 | onResponse:FShell.onResponseDefault(":function(args){ |
| 92 | eval(args.join(' ')); |
| 93 | }, |
| 94 | "login":function(args){ |
| 95 | FShell.fossil.login(args[1], args[2], { |
| 96 | onResponse:FShell.onResponseDefault() |
| 97 | }); |
| 98 | }, |
| 99 | "whoami":function(args){ |
| 100 | FShell.fossil.whoami({ |
| 101 | onResponse:FShell.onResponseDefault() |
| 102 | }); |
| 103 | }, |
| 104 | "HAI":function(args){ |
| 105 | FShell.fossil.HAI({ |
| 106 | onResponse:FShell.onResponseD}; |
| 107 | FShell.commandAliases = { |
| 108 | "li":"login", |
| 109 | "lo":"logout", |
| 110 | "who":"whoami", |
| 111 | "hi":"HAI", |
| 112 | "tci":"/timeline/ci?limit=3" |
| 113 | }; |
| 114 | FShell.mainLoop = funof java.lang['null'] = this.readlin = '+typeof line); |
| 115 | ; |
| 116 | } |
| 117 | print("Bye!h = this.commandHandlers[var FShell = { |
| 118 | serverUrl: |
| 119 | 'http://localhost:8080' |
| 120 | //'http://fjson/cgi-bin/fossil-json.cgi' |
| 121 | //'http://192.168.1.62:8080' |
| 122 | //'http://fossil.wanderinghorse.net/repos/fossil-json-java/index.cgi' |
| 123 | , |
| 124 | verbose:false, |
| 125 | prompt:"fossil shell > ", |
| 126 | wiki:{}, |
| 127 | consol:java.lang.System.console(), |
| 128 | v:function(msg){ |
| 129 | if(this.verbose){ |
| 130 | print("VERBOSE: "+msg); |
| 131 | } |
| 132 | } |
| 133 | }; |
| 134 | (function bootstrap() { |
| 135 | var srcdir = '../js/'; |
| 136 | var includes = [srcdir+'json2.js', |
| 137 | srcdir+'whajaj.js', |
| 138 | srcdir+'fossil-ajaj.js' |
| 139 | ]; |
| 140 | for( var i in includes ) { |
| 141 | load(includes[i]); |
| 142 | } |
| 143 | WhAjaj.Connector.prototype.sendImpl = WhAjaj.Connector.sendImpls.rhino; |
| 144 | FShell.fossil = new FossilAjaj({ |
| 145 | asynchronous:false, /* rhino-based impl doesn't support async. */ |
| 146 | timeout:10000, |
| 147 | url:FShell.serverUrl |
| 148 | }); |
| 149 | print("Server: "+FShell.serverUrl); |
| 150 | var cb = FShell.fossil.ajaj.callbacks; |
| 151 | cb.beforeSend = function(req,opt){ |
| 152 | if(!FShell.verbose) return; |
| 153 | print("SENDING REQUEST: AJAJ options="+JSON.stringify(opt)); |
| 154 | if(req) print("Request envelope="+WhAjaj.stringify(req)); |
| 155 | }; |
| 156 | cb.afterSend = function(req,opt){ |
| 157 | //if(!FShell.verbose) return; |
| 158 | //prin |