public void read_from_one_line() { var system = new FileSystem(); var path = directory.AppendPath("opts1.txt"); system.WriteStringToFile(path, "-f -a -b"); OptionReader.Read(path) .ShouldBe("-f -a -b"); }
private string applyOptions(string commandLine) { if (OptionsFile.IsEmpty()) { return(commandLine); } #if NET451 var path = AppDomain.CurrentDomain.BaseDirectory.AppendPath(OptionsFile); #else var path = AppContext.BaseDirectory.AppendPath(OptionsFile); #endif if (File.Exists(path)) { return($"{OptionReader.Read(path)} {commandLine}"); } return(commandLine); }
public void read_from_multiple_lines() { var path = directory.AppendPath("opts2.txt"); using (var stream = new FileStream(path, FileMode.Create)) { var writer = new StreamWriter(stream); writer.WriteLine("--color Blue"); writer.WriteLine("--size Medium "); writer.WriteLine(" --direction East"); writer.Flush(); writer.Dispose(); } OptionReader.Read(path) .ShouldBe("--color Blue --size Medium --direction East"); }
private IEnumerable <string> readOptions() { if (OptionsFile.IsEmpty()) { return(new string[0]); } #if NET451 var path = AppDomain.CurrentDomain.BaseDirectory.AppendPath(OptionsFile); #else var path = AppContext.BaseDirectory.AppendPath(OptionsFile); #endif if (File.Exists(path)) { var options = OptionReader.Read(path); return(StringTokenizer.Tokenize(options)); } return(new string[0]); }