private void RunImpl() { _console.SetTitle(Title); _console.WriteLine(Greeting); string input; while (true) { _console.Canceled = false; _console.SetTextStyle(ConsoleTextStyle.Normal); string prompt = (App.Status == AppStatus.WaitingMoreInput ? PromptMoreInput : Prompt); //Write prompt, read input, check for Ctrl-C _console.Write(prompt); input = _console.ReadLine(); if (_console.Canceled) { if (Confirm(Resources.MsgExitConsoleYN)) { return; } else { continue; //from the start of the loop } } //Execute App.ClearOutputBuffer(); EvaluateAsync(input); //Evaluate(input); WaitForScriptComplete(); switch (App.Status) { case AppStatus.Ready: //success _console.WriteLine(App.GetOutput()); break; case AppStatus.SyntaxError: _console.WriteLine(App.GetOutput()); //write all output we have _console.SetTextStyle(ConsoleTextStyle.Error); foreach (var err in App.GetParserMessages()) { _console.WriteLine(string.Empty.PadRight(prompt.Length + err.Location.Column) + "^"); //show err location _console.WriteLine(err.Message); //print message } break; case AppStatus.Crash: case AppStatus.RuntimeError: ReportException(); break; default: break; } //switch } } //Run method
public void Handle(IConsoleAdapter console) { console.WrapLine("Get user input".BGWhite().Black()); console.WriteLine(); var item = console.ReadInput(new {String = Read.String().Prompt("Enter some text".Yellow())}); var characters = item.String.Value .Select(c => string.Format(@"""{0}"" = {1}".Red(), ConsoleIOExtensions.Yellow(c.ToString()), string.Format("{0:X}", (byte) c).PadLeft(2, '0').Green())); console.WriteLine(); console.WrapLine(string.Join(" ", characters)); console.WriteLine(); console.ReadLine(); }
public void Handle(IConsoleAdapter console, IErrorAdapter error, Settings settings) { console.WriteLine("On average, encryption with compression is taking {0} to complete, press enter to continue..", ProcessingTime.GetAverageTime()); console.ReadLine(); ProcessingTime.StartTimer(); //the file is stored in a byte array called data var data = BufferUtils.GetFileContents(OriginalFile); //if they have selected the option of external key then the variable key will contain the //external key, otherwise the public key is taken from the settings object var key = OtherKey ? GetExternalKey() : settings.PublicKey; if (NoCompression) { //if the user selected the option no compression then the file is encrypted without compressing first data = PublicKeyEncryption.Encrypt(key, data); console.WrapLine("Encryption complete".Blue()); } else { //if the user didn't specify the option no compression then the file is compressed and then encrypted data = Compression.Compress(data); console.WrapLine("Compression complete".Green()); data = PublicKeyEncryption.Encrypt(key, data); console.WrapLine("Encryption complete".Blue()); } //the byte array is then written to the encrypted file location BufferUtils.WriteToFile(EncryptedFile, data); console.WrapLine("OriginalFile = {0}".Yellow(), OriginalFile.Cyan()); console.WrapLine("EncryptedFile = {0}".Yellow(), EncryptedFile.Cyan()); ProcessingTime.StopTimer(); }