public static void Main(string[] args) { bool help = false; var opts = new OptionSet() { { "h|help", "show this message and exit", v => help = true }, }; // All arguments that are not options or optional arguments. List <string> extra; try { extra = opts.Parse(args); } catch (OptionException e) { Console.WriteLine(e.Message); Console.WriteLine("Try `--help' for more information."); return; } if (help) { Usage(opts); return; } try { IISHandler handler = new IISHandler(); string kind = ""; if (!(extra.Count > 1)) { throw new ArgumentException("Not enough arguments."); } kind = extra[0]; if (kind.Equals("add")) { handler.AddApplicationPool(extra[1]); } else if (kind.Equals("remove")) { handler.RemoveApplicationPool(extra[1]); } else { Usage(opts); } } catch (Exception e) { Console.WriteLine(e.Message); } }