New command line options:
-b --backend puts it into backend mode, when in backend mode all other command line options are ignored.
In backend mode it reads commands from STDIN, responds to STDOUT.
commands consist of a single word command (made up only of word characters, typically all uppercase) optionally followed whitespace and arguments.
Responses consist of a single uppercase character, optionally followed by a single space and arguments.
SERVER <server> - Sets the server to use.
USERNAME <username> - sets username
PASSWORD <password> - sets password
DEFAULTSEC <seclevel> - sets the default security level.
AGENT <agentstring> - sets the user-agent http header.
PICSEC <seclevel> - sets the security level for the current set of images.
PUSHFILE <filename> - Adds a file to the upload queue.
PUSHGALLERY <galleryname> - Add a gallery to the list of galleries the queue of images is placed in.
UPLOAD - uploads all the files in the upload queue to the galleries specified in the gallery list. Clears both lists upon completion.
EXIT - Does cleanup, and exits.
I haven't figured out the best format for all of these yet, but here's a few.
S - the last command sent was successful.
F - The last command sent failed to execute.
E <human readable error message> - Sends and error string. I'm not sure whether or not it would be usefull to have a machine parsable error message too, if so the format would be:
E <errorcode> <human readable error message>
I haven't figured the best way to do progress bar info yet. it will likely look like this though:
U <shortname> - image successfully uploaded.
As I said, I haven't figured everything out here yet, there should probably be a bit more status information returned.
Note that the command may return an error and still manage to execute, e.g. one of the files doesn't exist, the rest may still be uploaded. In this case it sends the error, but still sends a success, if it fails it should almost always send an error message with why, but may not.
If you have any bright ideas about the best information to send for progress bars let me know, also from a front end perspective what other information is relevent? Right now I'm somewhat brain dead on the matter, I'll get better once I actually put together a front end for it though.
I'm also tempted to have the commands a bit more rigid, so that in the initial mode you can send SERVER, USERNAME, PASSWORD, AGENT, and DEFAULTSEC. Then you enter a different mode, perhaps with "UPLOAD BEGIN" where you can use the PUSHFILE and PUSHGALLERY commands, then send the UPLOAD END or UPLOAD EXEC or something to finish it.