I am going to be working on a command line program so I do not need to distract myself with GUI code and tryign to decide on how I want it to look but then I hit a wall because I started thinking: whats the best way to handle the commands.
Should I just take them and split the string? If so how do I handle command arguments that would be wrapped in quotes if they contain spaces?
Do I reuse the same list object for holding all parts of the command? Or maybe a whole command class, but then I have to limit the arguements somehow?
Anyone have good suggestions for me? I guess I could write a GUI but I tend to be really picky with that and waste more time on the GUI then I do the actual code and then it gets all tangled up. Plus if I did a GUI it would be WPF and that has its own learnign curve I am still fighting with.
Console application commands: best practices?
Page 1 of 14 Replies - 4242 Views - Last Post: 31 May 2011 - 03:06 PM
Replies To: Console application commands: best practices?
#2
Re: Console application commands: best practices?
Posted 19 May 2011 - 08:05 PM
Well, it depends. If you're talking about standard command line arguments, they 're stored in the args parameter of the Main method. So you can just get each from there. Those are the arguments that you pass when you start the program.
#4
Re: Console application commands: best practices?
Posted 30 May 2011 - 08:48 AM
Curtis Rutland, on 19 May 2011 - 11:05 PM, said:
Well, it depends. If you're talking about standard command line arguments, they 're stored in the args parameter of the Main method. So you can just get each from there. Those are the arguments that you pass when you start the program.
I don't mean arguements to start the program I am talking about have the user type somethign like this into my program:
start "C:\Program Files\Mozilla\Firefox.exe"
Or something similar. If I split it on the space then it breaks the filepath up, so I am wondering how to handle it.
#5
Re: Console application commands: best practices?
Posted 31 May 2011 - 03:06 PM
Well you could let the user give commands/parameters following a special character or a few like: -XF:Command Here. Then you could have spaces in the argument and just split where you need to. Or you could retrieve by index and then read until you get to another command.
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote






|