private static int Main(string[] args) { bool summary = true; bool logo = true; XmlStats xs = new XmlStats(); List <string> files = new List <string>(); for (int i = 0; i < args.Length; i++) { var arg = args[i]; if (arg.Length > 1 && arg[0] == '-') { string larg = arg.Trim('-').ToLower(CultureInfo.CurrentCulture); switch (larg) { case "?": case "h": case "help": PrintUsage(); return(1); case "f": if (i + 1 == args.Length) { Console.WriteLine("missing file name after '-f' argument"); PrintUsage(); return(1); } else { files = ReadFileNames(args[++i]); } break; case "v": summary = false; break; case "wn": xs._whiteSpace = WhitespaceHandling.None; break; case "ws": xs._whiteSpace = WhitespaceHandling.Significant; break; case "wa": xs._whiteSpace = WhitespaceHandling.All; break; case "nologo": logo = false; break; default: // invalid opt Console.WriteLine("invalid option '" + arg + "'"); PrintUsage(); return(1); } } else if (arg.IndexOf("://", StringComparison.InvariantCulture) > 0) { // url files.Add(arg); } else if (arg.IndexOf("*", StringComparison.InvariantCulture) >= 0 || arg.IndexOf("?", StringComparison.InvariantCulture) >= 0) { // resolve wildcards string path = Path.Combine(Directory.GetCurrentDirectory(), arg); string dir = Path.GetDirectoryName(path); string name = Path.GetFileName(path); string[] names = Directory.GetFiles(dir, name); foreach (string file in names) { files.Add(file); } } else { files.Add(arg); } } if (files.Count == 0) { PrintUsage(); return(1); } if (logo) { Console.WriteLine("*** XmlStats " + typeof(XmlStats).Assembly.GetName().Version.ToString() + " by Chris Lovett and Andreas Lang"); Console.WriteLine(); } xs.ProcessFiles(files.ToArray(), summary, Console.Out, "\n"); if (files.Count > 1) { Console.WriteLine("*** XmlStats ended."); } return(0); }
public static void Main(string[] args) { bool summary = true; bool logo = true; XmlStats xs = new XmlStats(); ArrayList files = new ArrayList(); foreach (string arg in args) { if (arg.Length > 1 && (arg[0] == '-' || arg[0] == '/')) { string larg = arg.Substring(1).ToLower(CultureInfo.CurrentCulture); switch (larg) { case "?": case "h": PrintUsage(); return; case "v": summary = false; break; case "wn": xs.whiteSpace = WhitespaceHandling.None; break; case "ws": xs.whiteSpace = WhitespaceHandling.Significant; break; case "wa": xs.whiteSpace = WhitespaceHandling.All; break; case "nologo": logo = false; break; default: // invalid opt Console.WriteLine("+++ invalid option ignored '" + arg + "'"); break; } } else if (arg.IndexOf("://", StringComparison.InvariantCulture) > 0) { // url files.Add(arg); } else if (arg.IndexOf("*", StringComparison.InvariantCulture) >= 0 || arg.IndexOf("?", StringComparison.InvariantCulture) >= 0) { // resolve wildcards string path = Path.Combine(Directory.GetCurrentDirectory(), arg); string dir = Path.GetDirectoryName(path); string name = Path.GetFileName(path); string[] names = Directory.GetFiles(dir, name); foreach (string file in names) { files.Add(file); } } else { files.Add(arg); } } if (logo) { Console.WriteLine("*** XmlStats V1.09 (March 2003)"); Console.WriteLine(" (by Chris Lovett and andreas lang,"); Console.WriteLine(" http://www.lovettsoftware.com/tools/xmlstats/readme.htm)"); Console.WriteLine(); } xs.ProcessFiles((string[])files.ToArray(typeof(string)), summary, Console.Out, "\n"); Console.WriteLine("*** XmlStats ended."); }