public override void Execute(ref IShellEngine engine, StringScanner s, Display display, InputCommand input) { if (s.Scan("false|off").Length > 0 && _writer != null) { display.TextWriters.Remove(_writer); input.OnWrite = null; _writer.Flush(); _writer.Dispose(); _writer = null; } else if (_writer == null) { if (engine == null) { throw ShellExpcetion.NoDatabase(); } var path = Path.GetFullPath(string.Format("LiteDB-spool-{0:yyyy-MM-dd-HH-mm}.txt", DateTime.Now)); _writer = File.CreateText(path); display.TextWriters.Add(_writer); input.OnWrite = (t) => _writer.Write(t); } }
public override void Execute(ref IShellEngine engine, StringScanner s, Display display, InputCommand input) { if (engine == null) { throw ShellExpcetion.NoDatabase(); } engine.Dispose(); engine = null; }
public override void Execute(ref IShellEngine engine, StringScanner s, Display d, InputCommand input) { var sb = new StringBuilder(); var enabled = !(s.Scan(@"off\s*").Length > 0); if (engine == null) { throw ShellExpcetion.NoDatabase(); } engine.Debug(enabled); }
public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env) { if (engine == null) { throw ShellExpcetion.NoDatabase(); } var filename = s.Scan(@".+").Trim(); foreach (var line in File.ReadAllLines(filename)) { input.Queue.Enqueue(line); } }
public override void Execute(ref IShellEngine engine, StringScanner s, Display display, InputCommand input) { if (engine == null) { throw ShellExpcetion.NoDatabase(); } var ver = engine.Version; display.WriteInfo(string.Format("v{0}.{1}.{2}", ver.Major, ver.Minor, ver.Build)); }
public override void Execute(ref IShellEngine engine, StringScanner s, Display display, InputCommand input) { if (engine == null) { throw ShellExpcetion.NoDatabase(); } var direction = s.Scan(@"[><]\s*").Trim(); var filename = s.Scan(@".+").Trim(); //dump import if (direction == "<") { using (var reader = new StreamReader(filename, Encoding.UTF8)) { string line; while ((line = reader.ReadLine()) != null) { engine.Run(line, new Display()); // no output } } } // dump export else { using (var writer = new StreamWriter(filename, false, Encoding.UTF8, 65536)) { writer.AutoFlush = true; writer.WriteLine("-- LiteDB v{0}.{1}.{2} dump file @ {3}", engine.Version.Major, engine.Version.Minor, engine.Version.Build, DateTime.Now); engine.Dump(writer); writer.Flush(); } } }