static public string ConsoleEditString(this string @default, string prefix = null) { var Editor = new LineEditor(null); Editor.TabAtStartCompletes = true; return Editor.Edit(prefix ?? "", @default); }
static void Main() { LineEditor le = new LineEditor("foo"); string s; while ((s = le.Edit("shell> ", "")) != null) { Console.WriteLine("----> [{0}]", s); } }
public void Interactive() { var lineEditor = new Mono.Terminal.LineEditor("muget"); string s; while ((s = lineEditor.Edit("muget> ", "")) != null) { Run(s.Split(' '), true); } }
private void Run() { Stopwatch stopwatch = new Stopwatch(); Console.Write("Constructing search tree..."); stopwatch.Start(); var wordFinder = new WordFinder(@"C:\Users\Daniel\Dropbox\Programming\TernarySearchTree\swedish-word-list-bigger.txt", Encoding.UTF8, Language.Swedish); //var wordFinder = new WordFinder(@"C:\Users\danlid\Dropbox\Programming\TernarySearchTree\english-word-list.txt", Encoding.UTF8, Language.English); //var wordFinder = new WordFinder(@"C:\Users\danlid\Dropbox\Programming\TernarySearchTree\swedish-english.txt", Encoding.UTF8, Language.Swedish); stopwatch.Stop(); Console.WriteLine("{0} ms", stopwatch.ElapsedMilliseconds); Console.WriteLine("Enter word to search for. A single 'q' exits."); var lineEditor = new LineEditor("input"); string input = lineEditor.Edit(": ", string.Empty); while (input != "q") { do { if (string.IsNullOrWhiteSpace(input)) break; stopwatch.Restart(); var matches = wordFinder.Matches(input, 2, 100); stopwatch.Stop(); if (matches.Count > 0) { Console.WriteLine("Found {0} words matching '{1}':", matches.Count, input); matches.ForEach(m => Console.WriteLine("{0,-7}: {1}", m.Type, m.Value)); } else { Console.WriteLine("Did not find any words matching '{0}'", input); } Console.WriteLine("Search completed in {0:F2} ms. Visited {1} nodes.", 1000.0 * stopwatch.ElapsedTicks / Stopwatch.Frequency, wordFinder.Nodes); } while (false); input = lineEditor.Edit(": ", string.Empty); } }
string GetLine(bool primary) { string prompt = primary ? InteractiveBase.Prompt : InteractiveBase.ContinuationPrompt; if (dumb) { if (isatty) { Console.Write(prompt); } return(Console.ReadLine()); } else { return(editor.Edit(prompt, "")); } }
static void Main() { LineEditor le = new LineEditor("foo") { HeuristicsMode = "csharp" }; le.AutoCompleteEvent += delegate(string a, int pos){ string prefix = ""; var completions = new string [] { "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten" }; return(new Mono.Terminal.LineEditor.Completion(prefix, completions)); }; string s; while ((s = le.Edit("shell> ", "")) != null) { Console.WriteLine("----> [{0}]", s); } }
public void Interactive() { var lineEditor = new Mono.Terminal.LineEditor ("muget"); string s; while ((s = lineEditor.Edit ("muget> ", "")) != null){ Run (s.Split (' '), true); } }
static void Main () { LineEditor le = new LineEditor (null); string s; while ((s = le.Edit ("shell> ", "")) != null){ Console.WriteLine ("----> [{0}]", s); } }
/// <summary> /// Method implements main application loop where application search configuration files, load them and /// then run LineEditor (emulator of Unix line terminal). /// </summary> private void Loop() { PreloadConfiguration(); String command; LineEditor = new LineEditor(null); LineEditor.AutoCompleteEvent += OnAutoComplete; LineEditor.TabKeyEvent += OnEditorTabKeyEvent; InvokeOnConfigurationLoaded(EventArgs.Empty); while ((command = LineEditor.Edit(CurrentSession.Prompt, "")) != null) { RunCommand(command); } }
public static int Main(string[] args) { var show_help = false; var use_precompiled = true; var options = new OptionSet { {"p|no-precomp", "do not use precompiled libraries", v => use_precompiled = v == null}, {"h|help", "show this message and exit", v => show_help = v != null} }; List<string> files; try { files = options.Parse(args); } catch (OptionException e) { Console.Error.Write(AppDomain.CurrentDomain.FriendlyName + ": "); Console.Error.WriteLine(e.Message); Console.Error.WriteLine("Try “" + AppDomain.CurrentDomain.FriendlyName + " --help” for more information."); return 1; } if (show_help) { Console.WriteLine("Usage: " + AppDomain.CurrentDomain.FriendlyName + " input.flbgst"); Console.WriteLine("Run Flabbergast interactively."); Console.WriteLine(); Console.WriteLine("Options:"); options.WriteOptionDescriptions(Console.Out); return 1; } if (files.Count > 1) { Console.Error.WriteLine("No more than one Flabbergast script may be given."); return 1; } Frame original = null; var assembly_builder = AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName("Repl"), AssemblyBuilderAccess.Run); var module_builder = assembly_builder.DefineDynamicModule("ReplModule"); var unit = new CompilationUnit(module_builder, false); var collector = new ConsoleCollector(); var task_master = new ConsoleTaskMaster(); task_master.AddUriHandler(BuiltInLibraries.INSTANCE); if (use_precompiled) { task_master.AddUriHandler(new LoadPrecompiledLibraries()); } task_master.AddUriHandler(new DynamicallyCompiledLibraries(collector)); if (files.Count == 1) { var parser = Parser.Open(files[0]); var root_type = parser.ParseFile(collector, unit, "REPLRoot"); if (root_type != null) { var computation = (Computation) Activator.CreateInstance(root_type, task_master); computation.Notify(r => original = r as Frame); task_master.Slot(computation); task_master.Run(); task_master.ReportCircularEvaluation(); } } if (original == null) { original = new Frame(task_master, task_master.NextId(), new SourceReference("<repl>", "<native>", 0, 0, 0, 0, null), null, null); } var id = 0; Frame current = original; bool run = true; ConsumeResult update_current = (x) => current = (x as Frame) ?? current; var line_editor = new LineEditor("flabbergast"); var completables = new Completables(); line_editor.AutoCompleteEvent = completables.Handler; string s; while (run && (s = line_editor.Edit(id + "‽ ", "")) != null) { var parser = new Parser("line" + id, s); var run_type = parser.ParseRepl(collector, unit, "REPL" + id++); if (run_type != null) { object result = null; var computation = (Computation) Activator.CreateInstance(run_type, new object[] { task_master, original, current, update_current, (ConsumeResult) (output => result = output), (ConsumeResult) Console.WriteLine }); computation.Notify(r => run = (r as bool?) ?? true); task_master.Slot(computation); task_master.Run(); if (result != null) { HandleResult(result); } task_master.ReportCircularEvaluation(); } } line_editor.SaveHistory(); return 0; }
internal static void CommandLoop() { Logger.WriteInfoLine("Welcome to the Mono Soft Debugger CLI!"); Logger.WriteInfoLine("Using {0} and {1} with features: {2}", typeof(VirtualMachine).Assembly.GetName().Name, typeof(SoftDebuggerSession).Assembly.GetName().Name, SoftDebugger.Features); Logger.WriteInfoLine("Type \"Help\" for a list of commands or \"Exit\" to quit."); var lineEditor = new LineEditor ("sdb"); string line; while (true) { line = lineEditor.Edit ("sdb> ", ""); if (line == null){ if (SoftDebugger.State != DebuggerState.Null && SoftDebugger.State != DebuggerState.Initialized){ var answer = lineEditor.Edit ("Do you really want to quit? (y/n) ", ""); if (answer == null || answer.ToLower ().StartsWith ("y")) break; } else break; } if (string.IsNullOrWhiteSpace(line)) continue; var fullCmd = line.Split(' '); var cmd = fullCmd[0]; var command = Dialect.Commands.SingleOrDefault(x => x.Key.Equals(cmd, StringComparison.OrdinalIgnoreCase)).Value; if (command == null) { Logger.WriteErrorLine("No such command: {0}", cmd); continue; } try { command.Execute(new CommandArguments(fullCmd.Skip(1))); } catch (Exception ex) { Logger.WriteErrorLine("Error executing command:", cmd); Logger.WriteErrorLine(ex.Message); if (!(ex is CommandArgumentException)) Logger.WriteErrorLine(ex.StackTrace); } if (Suspended) { ResumeEvent.WaitOne(); Suspended = false; } if (Stopped) break; } if (SoftDebugger.State != DebuggerState.Null) SoftDebugger.Stop(); if (Logger.LogOutput != null) { Logger.LogOutput.Dispose(); Logger.LogOutput = null; } }
static void Main () { LineEditor le = new LineEditor ("foo") { HeuristicsMode = "csharp" }; le.AutoCompleteEvent += delegate (string a, int pos){ string prefix = ""; var completions = new string [] { "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten" }; return new Mono.Terminal.LineEditor.Completion (prefix, completions); }; string s; while ((s = le.Edit ("shell> ", "")) != null){ Console.WriteLine ("----> [{0}]", s); } }
public void Run() { var le = new LineEditor( Config.ConsoleMode.AppName, Config.ConsoleMode.HistorySize.GetValueOrDefault(10)) { AutoCompleteEvent = (text, pos) => GetEntries(text) }; using (CommandsOptions.HideCommandOfType<ConsoleCommand>()) { Writer.WriteLines( "Type ctrl+c to exit.", "Type \"cls\" to clear the console window.", "Type \"> filename\" to redirect output to a file."); do { string[] args; do { args = le.Edit(Config.ConsoleMode.CommandPromptText + "> ", string.Empty).SplitCmdLineArgs(); } while (args.IsNullOrEmpty()); if (args[0].Equals("cls", StringComparison.OrdinalIgnoreCase)) { Console.Clear(); } else if (args[0].Equals(CommandName, StringComparison.OrdinalIgnoreCase)) { //already in console mode } else { le.SaveHistory(); RunCommand(args); } } while (true); } }
public static void Main(string[] args) { var c = new WebDavConnection (); bool show_help = false; bool show_version = false; var o = new OptionSet { "Usage: webdav [OPTIONS]", "", "Simple WebDav command-line client to excercise WebDavClient.", "", "Options:", { "server=", "Set name of WebDAV {SERVER} to connect to.", v => c.Builder.Server = new Uri (v) }, { "user="******"Set {USERNAME} on WebDAV server to connect to.", v => (c.Builder.NetworkCredential ?? (c.Builder.NetworkCredential = new NetworkCredential ())).UserName = v }, { "pass="******"Set {PASSWORD} on WebDAV server to connect to.", v => (c.Builder.NetworkCredential ?? (c.Builder.NetworkCredential = new NetworkCredential ())).Password = v }, { "v", "Show verbose communication information.", v => c.Builder.Log = Console.Out }, { "version", "Show version information and exit.", v => show_version = v != null }, { "help|h|?", "Show this message and exit.", v => show_help = v != null }, }; try { o.Parse (args); } catch (Exception ex) { Console.Error.WriteLine ("webdav: {0}", ex.Message); } if (show_version) { Console.WriteLine ("webdav 0.1"); return; } if (show_help) { o.WriteOptionDescriptions (Console.Out); return; } LineEditor e = new LineEditor ("webdav"); string s; while ((s = e.Edit ("webdav> ", "")) != null) { if ((s = s.Trim ()).Length == 0) continue; var p = s.IndexOf (' '); var m = p < 0 ? s : s.Substring (0, p); var a = WebDavConnection.GetCommand (m); if (a == null) { Console.Error.WriteLine ("webdav: Invalid command: {0}", s); continue; } while (p > 0 && p < s.Length && char.IsWhiteSpace (s, p)) ++p; s = p >= 0 && p < s.Length ? s.Substring (p) : ""; a (c, s); } }