commit 398dda11765a2ca16a16c2ed0dd758e7bab1d176
Author: Josh Kropf <josh@jiggak.slashdev.ca>
Date:   Sat Jan 24 16:35:52 2009 -0500

    Modified javaloader to use syntax similar to RIM's javaloader on windows

diff --git a/doc/javaloader_windows_usage.txt b/doc/javaloader_windows_usage.txt
new file mode 100644
index 0000000..69708eb
--- /dev/null
+++ b/doc/javaloader_windows_usage.txt
@@ -0,0 +1,84 @@
+Usage: JavaLoader [-u] [-p<port>|<pin>] [-b<baud>] [-d0|-d1] [-w<password>] [-q] <command>
+
+-u           Connect to USB handheld (default is serial)
+-p<port>     Specifies the serial port (serial handhelds only)
+-p<pin>      Specifies the handheld PIN (USB handhelds only)
+-b<baud>     Specifies the baud rate (serial handhelds only)
+-d0          Disables VM debug mode
+-d1          Enables VM debug mode
+-w<password> Connects using the specified password
+-q           Quiet mode
+
+<command> is of
+
+  dir [-d] [-s]
+    Lists modules on the handheld
+      -d     Display dependency information
+      -s     Display siblings
+
+  deviceinfo
+    Provides information on the handheld
+
+  load <.cod file> ...
+    Loads modules onto the handheld
+
+  save { <module> ... | -g <group> }
+    Retrieves modules from the handheld
+      -g     Retrieves all modules in a specified group
+
+  info [-d] [-v] <.cod file> ...
+    Provides information on the specified modules
+      -d     Display dependency information
+      -v     Display verbose module information
+
+  wipe [-a|-f]
+    Wipes the handheld
+      -a     Wipe applications only
+      -f     Wipe filesystem only
+
+  erase [-f] { <module> ... | -g <group> }
+    Erases modules on the handheld
+      -f     Force erase of in-use modules
+      -g     Erases all modules in a specified group
+
+  debugmode
+    Enables VM debug mode
+
+  eventlog
+    Retrives the handheld event log
+
+  cleareventlog
+    Clears the handheld event log
+
+  settime
+    Sets the time on the handheld to the current time
+
+  radio on|off
+    Turns the handheld's radio on or off
+
+  enum
+    Enumerates all USB handhelds
+
+  siblinginfo <.cod file> ...
+    Provides sibling information on the specified modules
+
+  screenshot <.bmp file>
+    Retreives the current screen contents and saves it as a BMP file
+
+  logstacktraces
+    Dumps the stack traces for all threads to the event log
+
+  recoverflash <size in bytes>
+    Attempts to recover the specified amount of flash
+
+  otasl load <type> file
+    load an OTASL patch file
+    type is os, dspos, osext, installer, cod or patchlist
+
+  otasl purge <type>
+    purge OTASL patch files
+    type is os, dspos, osext, installer, cod or patchlist
+
+  otasl state <state>
+    set the OTASL state and reset
+    state is APPLY_PATCH, BACKUP_DATA, etc
diff --git a/tools/bjavaloader.cc b/tools/bjavaloader.cc
index d480965..afa570d 100644
--- a/tools/bjavaloader.cc
+++ b/tools/bjavaloader.cc
@@ -36,6 +36,8 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 
+#define CMD_LIST "dir"
+#define CMD_LOAD "load"
 
 using namespace std;
 using namespace Barry;
@@ -51,14 +53,20 @@ void Usage()
    << "        Copyright 2005-2009, Net Direct Inc. (http://www.netdirect.ca/)\n"
    << "        Using: " << Version << "\n"
    << "\n"
-   << "   -f file   Load a new application\n"
    << "   -h        This help\n"
-   << "   -l        List COD files in device (use twice to list submodules)\n"
+   << "   -s        List sibling in module list\n"
    << "   -p pin    PIN of device to talk with\n"
    << "             If only one device is plugged in, this flag is optional\n"
    << "   -P pass   Simplistic method to specify device password\n"
    << "   -v        Dump protocol data during operation\n"
    << "\n"
+   << "commands\n"
+   << "\n"
+   << "   " << CMD_LIST << endl
+   << "      Lists modules on the handheld\n"
+   << "\n"
+   << "   " << CMD_LOAD << " <.cod file> ...\n"
+   << "      Loads modules onto the handheld\n"
    << endl;
 }
 
@@ -163,12 +171,10 @@ int main(int argc, char *argv[])
 	try {
 
 		uint32_t pin = 0;
-		bool load = false,
-			list_java = false,
-			list_sub = false,
+		bool list_siblings = false,
 			data_dump = false;
 		string password;
-		string filename;
+		vector<string> params;
 		string busname;
 		string devname;
 		string iconvCharset;
@@ -176,7 +182,7 @@ int main(int argc, char *argv[])
 
 		// process command line options
 		for(;;) {
-			int cmd = getopt(argc, argv, "f:hlp:P:v");
+			int cmd = getopt(argc, argv, "hsp:P:v");
 			if( cmd == -1 )
 				break;
 
@@ -190,16 +196,8 @@ int main(int argc, char *argv[])
 				password = optarg;
 				break;
 
-			case 'f':	// Filename
-				load = true;
-				filename = optarg;
-				break;
-
-			case 'l':	// list device COD files
-				if( !list_java )
-					list_java = true;
-				else
-					list_sub = true;
+			case 's':	// turn on listing of sibling modules
+				list_siblings = true;
 				break;
 
 			case 'v':	// data dump on
@@ -212,6 +210,25 @@ int main(int argc, char *argv[])
 				return 0;
 			}
 		}
+		
+		argc -= optind;
+		argv += optind;
+
+		if( argc < 1 ) {
+			cerr << "missing command" << endl;
+			Usage();
+			return 1;
+		}
+		
+		// Fetch command from remaining arguments
+		string cmd = argv[0];
+		argc --;
+		argv ++;
+
+		// Put the remaining arguments into an array
+		for (; argc > 0; argc --, argv ++) {
+			params.push_back(string(argv[0]));
+		}
 
 		// Initialize the barry library.  Must be called before
 		// anything else.
@@ -237,14 +254,27 @@ int main(int argc, char *argv[])
 		javaloader.Open(password.c_str());
 		javaloader.StartStream();
 
-		// Send the file
-		if( load )
-			SendAppFile(&javaloader, filename.c_str());
-
-		if( list_java ) {
+		if( cmd == CMD_LIST ) {
 			JLDirectory dir;
-			javaloader.GetDirectory(dir, list_sub);
+			javaloader.GetDirectory(dir, list_siblings);
 			cout << dir;
+		} else if( cmd == CMD_LOAD ) {
+			if( params.size() == 0 ) {
+				// FIXME is this necessary?
+				javaloader.StopStream();
+				
+				cerr << "specify at least one .cod file to load" << endl;
+				Usage();
+				
+				return 1;
+			}
+			
+			vector<string>::iterator i = params.begin();
+			for( ; i != params.end(); ++i ) {
+				cout << "loading " << (*i) << "... ";
+				SendAppFile(&javaloader, (*i).c_str());
+				cout << "done." << endl;
+			}
 		}
 
 		// Stop
