public void SettingsFromArgs_NoArgs_HasDefaultValues() { var settings = _searchOptions.SettingsFromArgs(new List <string>()); Assert.IsFalse(settings.ArchivesOnly); Assert.IsTrue(settings.Colorize); Assert.IsFalse(settings.Debug); Assert.IsTrue(settings.ExcludeHidden); Assert.IsFalse(settings.FirstMatch); Assert.AreEqual(0, settings.LinesAfter); Assert.AreEqual(0, settings.LinesBefore); Assert.IsFalse(settings.ListDirs); Assert.IsFalse(settings.ListFiles); Assert.IsFalse(settings.ListLines); Assert.AreEqual(150, settings.MaxLineLength); Assert.IsFalse(settings.MultiLineSearch); Assert.IsTrue(settings.PrintResults); Assert.IsFalse(settings.PrintUsage); Assert.IsFalse(settings.PrintVersion); Assert.IsTrue(settings.Recursive); Assert.IsFalse(settings.SearchArchives); Assert.AreEqual(null, settings.StartPath); Assert.IsFalse(settings.UniqueLines); Assert.IsFalse(settings.Verbose); }
static void Main(string[] args) { var options = new SearchOptions(); try { var settings = options.SettingsFromArgs(args); if (settings.Debug) { Common.Log("settings: " + settings + "\n"); } if (settings.PrintUsage) { options.Usage(); } var searcher = new Searcher(settings); searcher.Search(); if (settings.PrintResults) { Common.Log(""); searcher.PrintResults(); } if (settings.ListDirs) { searcher.PrintMatchingDirs(); } if (settings.ListFiles) { searcher.PrintMatchingFiles(); } if (settings.ListLines) { searcher.PrintMatchingLines(); } } catch (SearchException e) { Common.Log($"\nERROR: {e.Message}"); options.Usage(1); } }