iccaros Posted April 4, 2008 Report Share Posted April 4, 2008 I know how to take strait arguments into C# but I am writing a console application that I would like to add agrumnets like -f or -F and a space then the agrgumentso it would look like a good unix command example command mydile.txt -p C:\user\username -lmy thought is to treat the flag as an argument then read the next one for the value ..but I am not sure if there is a better way, as I can see this getting complex.. depending on how much the tool can do.. Quote Link to post Share on other sites
jcl Posted April 5, 2008 Report Share Posted April 5, 2008 That's pretty much how it's done on Unix. Iterate through the argument vector, when you find a flag that takes an argument at argv[n], grab the argument from argv[n+1] and bump n for the next pass. If you want a general solution, look at Unix's getopt(3) for inspiration.(On the off chance that you're using GTK#, you might check if it includes GLib's GOption command-line parser.) Quote Link to post Share on other sites
iccaros Posted April 5, 2008 Author Report Share Posted April 5, 2008 thanks..getops is a good example..now back to work Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.