added an 'introspect' command
authorerickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Wed, 16 Mar 2005 03:07:17 +0000 (03:07 +0000)
committererickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Wed, 16 Mar 2005 03:07:17 +0000 (03:07 +0000)
git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@238 9efc2488-bf62-4759-914b-345cdb29e865

src/srfsh/srfsh.c
src/srfsh/srfsh.h

index d62b281..85f63bf 100644 (file)
@@ -167,6 +167,9 @@ int parse_request( char* request ) {
        else if (!strcmp(words[0],"math_bench"))
                ret_val = handle_math(words);
 
+       else if (!strcmp(words[0],"introspect"))
+               ret_val = handle_introspect(words);
+
        else if (words[0][0] == '!')
                ret_val = handle_exec( words );
 
@@ -177,6 +180,22 @@ int parse_request( char* request ) {
 
 }
 
+
+int handle_introspect(char* words[]) {
+
+       if(words[1]) {
+               fprintf(stderr, "--> %s\n", words[1]);
+               char buf[256];
+               memset(buf,0,256);
+               sprintf( buf, "request %s opensrf.system.method.all", words[1] );
+               return parse_request( buf );
+       }
+
+       return 0;
+}
+
+
+
 int handle_set( char* words[]) {
 
        char* variable;
@@ -501,19 +520,27 @@ int print_help() {
                        "set <variable> <value> - set a srfsh variable (e.g. set pretty_print true )\n"
                        "print <variable>               - Displays the value of a srfsh variable\n"
                        "---------------------------------------------------------------------------------\n"
+
                        "router query servers <server1 [, server2, ...]>\n"
                        "       - Returns stats on connected services\n"
                        "\n"
+                       "\n"
                        "request <service> <method> [ <json formatted string of params> ]\n"
                        "       - Anything passed in will be wrapped in a json array,\n"
                        "               so add commas if there is more than one param\n"
                        "\n"
+                       "\n"
                        "relay <service> <method>\n"
                        "       - Performs the requested query using the last received result as the param\n"
                        "\n"
+                       "\n"
                        "math_bench <num_batches> [0|1|2]\n"
                        "       - 0 means don't reconnect, 1 means reconnect after each batch of 4, and\n"
                        "                2 means reconnect after every request\n"
+                       "\n"
+                       "introspect <service>\n"
+                       "       - prints the API for the service\n"
+                       "\n"
                        "---------------------------------------------------------------------------------\n"
                        "Note: long output is piped through 'less'.  To search in 'less', type: /<search>\n"
                        "---------------------------------------------------------------------------------\n"
index 37af2f8..ab5902d 100644 (file)
@@ -60,6 +60,5 @@ void sig_int_handler( int s );
 int load_history();
 int handle_math( char* words[] );
 int do_math( int count, int style );
-
-
+int handle_introspect(char* words[]);