static void Main(string[] args) { if (args.Length == 0) { Console.WriteLine("WordStats (options) file"); } else if (args.Any(x => x == "--help" || x == "-h")) { Console.WriteLine("WordStats"); Console.WriteLine(" WordStats (options) file"); Console.WriteLine(); Console.WriteLine(" options:"); Console.WriteLine(" --help, --h: this message"); Console.WriteLine(" @(fileName): setting file name"); } else { string?filePath = null; string?settingFilePath = null; foreach (var item in args) { if (item.StartsWith("@")) { settingFilePath = item.Substring(1); } else { filePath = item; } } if (string.IsNullOrWhiteSpace(filePath)) { throw new ArgumentException($"invalid dictionary name: {filePath}"); } WordStatsSettings settings = GetSettings(settingFilePath); IWordDictionary dictionary = GetDictionary(settings.Dictionary); dictionary.ReadFile(filePath); IList <IWordCategorizer> categorizers = GetCategorizers(settings.Categorizers); IWordStatistics statistics = GetStatistics(settings.Statistics, settings.Order); statistics.Dictionary = dictionary; statistics.Execute(categorizers); } }