static int Main(string[] args) { bool quiet; bool nologo; SourceServerIndexer indexer = LoadIndexer(args, out quiet, out nologo); if (!quiet && !nologo) { Console.Write(((AssemblyProductAttribute)typeof(Program).Assembly.GetCustomAttributes(typeof(AssemblyProductAttribute), false)[0]).Product); AssemblyName name = new AssemblyName(typeof(Program).Assembly.FullName); Console.WriteLine(" " + name.Version.ToString(4)); Console.WriteLine(((AssemblyCopyrightAttribute)typeof(Program).Assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false)[0]).Copyright); Console.WriteLine("The sourcecode of this program has been released under the Apache licence."); Console.WriteLine(); } if (indexer == null) { ShowHelp(); return(1); } IndexerResult result = indexer.Exec(); if (!result.Success) { Console.Error.WriteLine(result.ErrorMessage); return(1); } if (!quiet) { Console.WriteLine("Added {0}/{1} references to {2} symbolfile(s) with {3} provider(s).", result.IndexedSourceFiles, result.TotalSourceFiles, result.IndexedSymbolFiles, result.ProvidersUsed); } return(0); // C }
private static SourceServerIndexer LoadIndexer(string[] args, out bool quiet, out bool nologo) { SourceServerIndexer indexer = new SourceServerIndexer(); quiet = false; nologo = false; int i; for (i = 0; i < args.Length; i++) { bool breakOut = false; string arg = args[i]; string param = (i + 1 < args.Length) ? args[i + 1] : null; if (arg == "/?") { return(null); // Special case default help mode } if (arg.Length > 1 && arg[0] == '-') { switch (arg.Substring(1).ToLowerInvariant()) { case "-": breakOut = true; break; case "?": case "h": case "help": return(null); // We show help case "nologo": nologo = true; break; case "q": case "quiet": quiet = true; break; case "f": case "force": indexer.ReIndexPreviouslyIndexedSymbols = true; break; case "i": case "inc": case "include": if (param == null) { return(null); // Show help and exit with errorlevel 1 } if (param.Contains("?") || param.Contains("*")) { foreach (string item in ExpandGlob(param, true, true)) { indexer.SourceRoots.Add(Path.GetFullPath(item)); } } else { indexer.SourceRoots.Add(Path.GetFullPath(param)); } i++; // Skip next argument break; case "x": case "exc": case "exclude": if (param == null) { return(null); // Show help and exit with errorlevel 1 } if (param.Contains("?") || param.Contains("*")) { foreach (string item in ExpandGlob(param, true, true)) { indexer.ExcludeSourceRoots.Add(Path.GetFullPath(item)); } } else { indexer.ExcludeSourceRoots.Add(Path.GetFullPath(param)); } i++; // Skip next argument break; default: Console.Error.WriteLine("Unknown argument '{0}'", arg); return(null); } if (breakOut) { i++; break; } } else { break; } } if (i >= args.Length) { return(null); // Show help } for (; i < args.Length; i++) { string param = args[i]; if (param.Contains("?") || param.Contains("*")) { foreach (string item in ExpandGlob(param, false, true)) { indexer.SymbolFiles.Add(SvnTools.GetNormalizedFullPath(item)); } } else { indexer.SymbolFiles.Add(SvnTools.GetNormalizedFullPath(param)); } } return(indexer); }