Fossil

Diff
Login

Differences From Artifact [67e3d6ce54]:

To Artifact [23b188f63e]:


49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
    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);
        }
    });
})();

/**







|







49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
    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);
        }
    });
})();

/**
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
        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);







>
>
>
>
|

|
>
>


|





|
<
|

|
>
>
>







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
        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);
151
152
153
154
155
156
157
158



159
160








161
162
163
164
165

166
167
168
169
            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();







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





>




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
            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();