public static string ReadPassword() { var password = ConsoleNativeMethods.ReadPassword(); System.Console.WriteLine(); return(password); }
public static string ReadPassword() { var password = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ConsoleNativeMethods.ReadPassword() : InternalReadPassword(); System.Console.WriteLine(); return(password); }
private async Task <Uri> RecursiveDiscoverServer(int iteration, bool noInteractive) { var server = new Uri($"http://localhost:{Port + iteration}"); if (!await server.IsServerRunningAsync()) { // create the server if (_settings.DisplayLaunchingRunServerWarning && !noInteractive) { ColoredConsole .WriteLine() .WriteLine("We need to launch a server that will host and run your functions.") .WriteLine("The server will auto load any changes you make to the function."); string answer = null; do { ColoredConsole .Write(QuestionColor("Do you want to always display this warning before launching a new server [yes/no]? [yes] ")); answer = Console.ReadLine()?.Trim()?.ToLowerInvariant(); answer = string.IsNullOrEmpty(answer) ? "yes" : answer; } while (answer != "yes" && answer != "no"); _settings.DisplayLaunchingRunServerWarning = answer == "yes" ? true : false; } //TODO: factor out to PlatformHelper.LaunchInNewConsole and implement for Mac using AppleScript var exeName = System.Reflection.Assembly.GetEntryAssembly().Location; var exe = PlatformHelper.IsWindows ? new Executable(exeName, $"host start -p {Port + iteration} --pause-on-error", streamOutput: false, shareConsole: true) : new Executable("mono", $"{exeName} host start -p {Port + iteration} --pause-on-error", streamOutput: false, shareConsole: false); exe.RunAsync().Ignore(); await Task.Delay(500); if (PlatformHelper.IsWindows) { ConsoleNativeMethods.GetFocusBack(); } return(server); } else { if (await IsRightServer(server)) { return(server); } else { return(await RecursiveDiscoverServer(iteration + 1, noInteractive)); } } }
private async Task <Uri> DiscoverServer(int iteration = 0) { var server = new Uri($"http://localhost:{Port + iteration}"); if (!await server.IsServerRunningAsync()) { // create the server if (_settings.DisplayLaunchingRunServerWarning) { ColoredConsole .WriteLine() .WriteLine("We need to launch a server that will host and run your functions.") .WriteLine("The server will auto load any changes you make to the function."); string answer = null; do { ColoredConsole .Write(QuestionColor("Do you want to always display this warning before launching a new server [yes/no]? [yes] ")); answer = Console.ReadLine()?.Trim()?.ToLowerInvariant(); answer = string.IsNullOrEmpty(answer) ? "yes" : answer; } while (answer != "yes" && answer != "no"); _settings.DisplayLaunchingRunServerWarning = answer == "yes" ? true : false; } //TODO: factor out to PlatformHelper.LaunchInNewConsole and implement for Mac using AppleScript var exeName = System.Reflection.Assembly.GetEntryAssembly().Location; var exe = PlatformHelper.IsWindows ? new Executable(exeName, $"host start -p {Port + iteration}", streamOutput: false, shareConsole: true) : new Executable("mono", $"{exeName} host start -p {Port + iteration}", streamOutput: false, shareConsole: false); exe.RunAsync().Ignore(); await Task.Delay(500); if (PlatformHelper.IsWindows) { ConsoleNativeMethods.GetFocusBack(); } return(server); } else { var hostId = await GetHostId(ScriptHostHelpers.GetFunctionAppRootDirectory(Environment.CurrentDirectory)); using (var client = new HttpClient()) { var response = await client.GetAsync(new Uri(server, "admin/host/status")); response.EnsureSuccessStatusCode(); var hostStatus = await response.Content.ReadAsAsync <HostStatus>(); if (!hostStatus.Id.Equals(hostId, StringComparison.OrdinalIgnoreCase)) { return(await DiscoverServer(iteration + 1)); } else { return(server); } } } }