/// <summary>Entry point in to ConsoleShell. This method is called by main of minishell.</summary> /// <param name="bannerText">Banner text to be displayed by ConsoleHost</param> /// <param name="helpText">Help text for minishell. This is displayed on 'minishell -?'.</param> /// <param name="args">Commandline parameters specified by user.</param> /// <returns>An integer value which should be used as exit code for the process.</returns> public static int Start(string bannerText, string helpText, string[] args) { if (args == null) { throw PSTraceSource.NewArgumentNullException("args"); } return(ConsoleHost.Start(bannerText, helpText, args)); }
internal static int Start(RunspaceConfiguration configuration, string bannerText, string helpText, string preStartWarning, string[] args) { if (args != null) { ConsoleControl.UpdateLocaleSpecificFont(); return(ConsoleHost.Start(configuration, bannerText, helpText, preStartWarning, args)); } else { throw PSTraceSource.NewArgumentNullException("args"); } }
Start(RunspaceConfiguration configuration, string bannerText, string helpText, string preStartWarning, string[] args) { if (args == null) { throw PSTraceSource.NewArgumentNullException("args"); } return(ConsoleHost.Start(configuration, bannerText, helpText, preStartWarning, args)); }
/// <summary>Entry point in to ConsoleShell. Used to create a custom Powershell console application.</summary> /// <param name="initialSessionState">InitialSessionState to be used by the ConsoleHost.</param> /// <param name="bannerText">Banner text to be displayed by ConsoleHost.</param> /// <param name="helpText">Help text for the shell.</param> /// <param name="args">Commandline parameters specified by user.</param> /// <returns>An integer value which should be used as exit code for the process.</returns> public static int Start(InitialSessionState initialSessionState, string bannerText, string helpText, string[] args) { if (initialSessionState == null) { throw PSTraceSource.NewArgumentNullException(nameof(initialSessionState)); } if (args == null) { throw PSTraceSource.NewArgumentNullException(nameof(args)); } ConsoleHost.DefaultInitialSessionState = initialSessionState; return(ConsoleHost.Start(bannerText, helpText, args)); }
private static int StartImpl( InitialSessionState initialSessionState, string?bannerText, string?helpText, string[] args, bool issProvided) { if (initialSessionState == null) { throw PSTraceSource.NewArgumentNullException(nameof(initialSessionState)); } if (args == null) { throw PSTraceSource.NewArgumentNullException(nameof(args)); } ConsoleHost.ParseCommandLine(args); ConsoleHost.DefaultInitialSessionState = initialSessionState; return(ConsoleHost.Start(bannerText, helpText, issProvided)); }
Start(RunspaceConfiguration configuration, string bannerText, string helpText, string preStartWarning, string[] args) { if (args == null) { throw PSTraceSource.NewArgumentNullException("args"); } // The default font face used for Powershell Console is Lucida Console. // However certain CJK locales dont support Lucida Console font. Hence for such // locales the console font is updated to Raster dynamically. // For NanoServer: // 1. There is no GetCurrentConsoleFontEx / SetCurrentConsoleFontEx on NanoServer; // 2. We don't handle CJK locales on NanoServer due to lack of win32 API supports on NanoServer. #if !CORECLR ConsoleControl.UpdateLocaleSpecificFont(); #endif return(ConsoleHost.Start(configuration, bannerText, helpText, preStartWarning, args)); }
public static int Start([MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeParamIndex = 1)] string[] args, int argc) { if (args == null) { throw new ArgumentNullException(nameof(args)); } #if DEBUG if (args.Length > 0 && !string.IsNullOrEmpty(args[0]) && args[0] !.Equals("-isswait", StringComparison.OrdinalIgnoreCase)) { Console.WriteLine("Attach the debugger to continue..."); while (!System.Diagnostics.Debugger.IsAttached) { Thread.Sleep(100); } System.Diagnostics.Debugger.Break(); } #endif // Warm up some components concurrently on background threads. EarlyStartup.Init(); // Windows Vista and later support non-traditional UI fallback ie., a // user on an Arabic machine can choose either French or English(US) as // UI fallback language. // CLR does not support this (non-traditional) fallback mechanism. // The currentUICulture returned NativeCultureResolver supports this non // traditional fallback on Vista. So it is important to set currentUICulture // in the beginning before we do anything. Thread.CurrentThread.CurrentUICulture = NativeCultureResolver.UICulture; Thread.CurrentThread.CurrentCulture = NativeCultureResolver.Culture; ConsoleHost.ParseCommandLine(args); // NOTE: On Unix, logging depends on a command line parsing // and must be just after ConsoleHost.ParseCommandLine(args) // to allow overriding logging options. PSEtwLog.LogConsoleStartup(); int exitCode = 0; try { var banner = string.Format( CultureInfo.InvariantCulture, ManagedEntranceStrings.ShellBannerNonWindowsPowerShell, PSVersionInfo.GitCommitId); ConsoleHost.DefaultInitialSessionState = InitialSessionState.CreateDefault2(); exitCode = ConsoleHost.Start(banner, ManagedEntranceStrings.UsageHelp); } catch (HostException e) { if (e.InnerException is Win32Exception win32e) { // These exceptions are caused by killing conhost.exe // 1236, network connection aborted by local system // 0x6, invalid console handle if (win32e.NativeErrorCode == 0x6 || win32e.NativeErrorCode == 1236) { return(exitCode); } } System.Environment.FailFast(e.Message, e); } catch (Exception e) { System.Environment.FailFast(e.Message, e); } return(exitCode); }