views:

169

answers:

2

I am thinking of writing a java application to wrap CVS and some of our other custom build/deploy scripts. This way it will be easy to view status, do a build, publish and deploy without having to type in the commands. What is the easiest way to do this?

Offhand I'd guess I have to redirect the output from the command to a String and parse it for the information I want.

Any other techniques/suggestions?

+2  A: 

For parsing command-line arguments, I recommend args4j.

UPDATE: Based on your problem description, it sounds like any or all of the following would be better options than rolling your own: Hudson, Capistrano, Fabric, or just plain-old shell scripting.

UPDATE 2: Based on the downvote and comment, you seem to be interested in interacting with the command line from the other side, i.e., driving the command line, not being driven by the command line. In that case, bitter experience suggests that Java is emphatically not the best choice. Almost any "scripting" language is a better fit. If you still want to do it, there's always ProcessBuilder and friends.

Hank Gay
What does this have to do with my question. I am asking about interacting with a command line, not command line arguements.
windfinder
Sorry; misinterpreted your question. In my defense, reading input from the command-line very much counts as "interacting with the command-line".
Hank Gay
+1  A: 

I answered a similar question some days ago:

http://stackoverflow.com/questions/1369860/implementing-the-system-command-in-java/1372176#1372176

Wrapping a command-line call is a bit tricky.

Carlos Tasada