Fossil

Check-in [d30b20a5]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:minor tweaks to the prototype shell.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | json-multitag-test | json
Files: files | file ages | folders
SHA1:d30b20a56c620c6f9f5a97bee8f34dc6ea9e5bce
User & Date: stephan 2011-10-07 13:32:38
Context
2011-10-07
13:51
First draft, no-frills /json/diff added. check-in: 54e1f1a5 user: stephan tags: json-multitag-test, json-add-tag-test, json
13:32
minor tweaks to the prototype shell. check-in: d30b20a5 user: stephan tags: json-multitag-test, json
12:02
Added a very, very prototypic/pre-alphalpha demo fossil shell. Requires rhino JS. check-in: 7ab5d854 user: stephan tags: json-multitag-test, json
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ajax/i-test/rhino-shell.js.

49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
...
112
113
114
115
116
117
118




119
120
121


122
123
124
125
126
127
128
129
130
131
132
133
134



135
136
137
138
139
140
141
...
151
152
153
154
155
156
157
158



159
160








161
162
163
164
165

166
167
168
169
    cb.onResponse = function(resp,req){
        if(!FShell.verbose) return;
        if(resp && resp.resultCode){
            print("Response contains error info: "+resp.resultCode+": "+resp.resultText);
        }
        print("GOT RESPONSE: "+(('string'===typeof resp) ? resp : WhAjaj.stringify(resp)));
    };
    FShell.fossil.whoami({
        onResponse:function(resp,opt){
            assertResponseOK(resp);
        }
    });
})();

/**
................................................................................
        return String(stdin.readLine()); 
     };
}());

FShell.dispatchLine = function(line){
    var av = line.split(' '); // FIXME: to shell-like tokenization. Too tired!
    var cmd = av[0];




    var h = this.commandHandlers[('/' == cmd[0]) ? '/' : cmd];
    if(!h){
        print("Command not known: "+cmd);


    }
    else{
        print("Sending ["+cmd+"] command... ");
        try{h(av);}
        catch(e){ print("EXCEPTION: "+e); }
    }
};

FShell.onResponseDefault = function(){
    var self = this;
    return function(resp){
        assertResponseOK(resp);
        print(WhAjaj.stringify(resp.payload));



    };
};
FShell.commandHandlers = {
    "/":function(args){
        FShell.fossil.sendCommand('/json'+args[0],undefined,{
            beforeSend:function(req,opt){
                print("Sending to: "+opt.url);
................................................................................
            onResponse:FShell.onResponseDefault()
        });
    },
    "whoami":function(args){
        FShell.fossil.whoami({
            onResponse:FShell.onResponseDefault()
        });
    }



};









FShell.mainLoop = function(){
    var line;
    while( null != (line = this.readline(this.prompt)) ){
        //print("Got line: "+line);
        this.dispatchLine(line);

    }
};

FShell.mainLoop();







|







 







>
>
>
>
|

|
>
>


|





|
<
|

|
>
>
>







 







|
>
>
>
|
|
>
>
>
>
>
>
>
>





>




49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
...
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136

137
138
139
140
141
142
143
144
145
146
147
148
149
...
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
    cb.onResponse = function(resp,req){
        if(!FShell.verbose) return;
        if(resp && resp.resultCode){
            print("Response contains error info: "+resp.resultCode+": "+resp.resultText);
        }
        print("GOT RESPONSE: "+(('string'===typeof resp) ? resp : WhAjaj.stringify(resp)));
    };
    FShell.fossil.HAI({
        onResponse:function(resp,opt){
            assertResponseOK(resp);
        }
    });
})();

/**
................................................................................
        return String(stdin.readLine()); 
     };
}());

FShell.dispatchLine = function(line){
    var av = line.split(' '); // FIXME: to shell-like tokenization. Too tired!
    var cmd = av[0];
    var key, h;
    if('/' == cmd[0]) key = '/';
    else key = this.commandAliases[cmd];
    if(!key) key = cmd;
    h = this.commandHandlers[key];
    if(!h){
        print("Command not known: "+cmd +" ("+key+")");
    }else if(!WhAjaj.isFunction(h)){
        print("Not a function: "+key);
    }
    else{
        print("Sending ["+key+"] command... ");
        try{h(av);}
        catch(e){ print("EXCEPTION: "+e); }
    }
};

FShell.onResponseDefault = function(callback){

    return function(resp,req){
        assertResponseOK(resp);
        print("Payload: "+(resp.payload ? WhAjaj.stringify(resp.payload) : "none"));
        if(WhAjaj.isFunction(callback)){
            callback(resp,req);
        }
    };
};
FShell.commandHandlers = {
    "/":function(args){
        FShell.fossil.sendCommand('/json'+args[0],undefined,{
            beforeSend:function(req,opt){
                print("Sending to: "+opt.url);
................................................................................
            onResponse:FShell.onResponseDefault()
        });
    },
    "whoami":function(args){
        FShell.fossil.whoami({
            onResponse:FShell.onResponseDefault()
        });
    },
    "HAI":function(args){
        FShell.fossil.HAI({
            onResponse:FShell.onResponseDefault()
        });
    }
};
FShell.commandAliases = {
    "li":"login",
    "lo":"logout",
    "who":"whoami",
    "hi":"HAI",
    "tci":"/timeline/ci?limit=3"
};
FShell.mainLoop = function(){
    var line;
    while( null != (line = this.readline(this.prompt)) ){
        //print("Got line: "+line);
        this.dispatchLine(line);
        print("");
    }
};

FShell.mainLoop();