// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. using System.Collections.Generic; using System.Management.Automation.Host; using System.Management.Automation.Runspaces; namespace Microsoft.PowerShell.EditorServices.Hosting { /// /// Describes the desired console REPL for the Extension Terminal. /// public enum ConsoleReplKind { /// No console REPL - there will be no interactive console available. None = 0, /// Use a REPL with the legacy readline implementation. This is generally used when PSReadLine is unavailable. LegacyReadLine = 1, /// Use a REPL with the PSReadLine module for console interaction. PSReadLine = 2, } /// /// Configuration for editor services startup. /// public sealed class EditorServicesConfig { /// /// Create a new editor services config object, /// with all required fields. /// /// The host description object. /// The PowerShell host to use in Editor Services. /// The path to use for the session details file. /// The path to the modules bundled with Editor Services. /// The path to be used for Editor Services' logging. public EditorServicesConfig( HostInfo hostInfo, PSHost psHost, string sessionDetailsPath, string bundledModulePath, string logPath) { HostInfo = hostInfo; PSHost = psHost; SessionDetailsPath = sessionDetailsPath; BundledModulePath = bundledModulePath; LogPath = logPath; } /// /// The host description object. /// public HostInfo HostInfo { get; } /// /// The PowerShell host used by Editor Services. /// public PSHost PSHost { get; } /// /// The path to use for the session details file. /// public string SessionDetailsPath { get; } /// /// The path to the modules bundled with EditorServices. /// public string BundledModulePath { get; } /// /// The path to use for logging for Editor Services. /// public string LogPath { get; } /// /// Names of or paths to any additional modules to load on startup. /// public IReadOnlyList AdditionalModules { get; set; } /// /// Flags of features to enable on startup. /// public IReadOnlyList FeatureFlags { get; set; } /// /// The console REPL experience to use in the Extension Terminal /// (including none to disable the Extension Terminal). /// public ConsoleReplKind ConsoleRepl { get; set; } = ConsoleReplKind.None; /// /// Will suppress messages to PSHost (to prevent Stdio clobbering) /// public bool UseNullPSHostUI { get; set; } /// /// The minimum log level to log events with. Defaults to warning but is usually overriden by the startup process. /// public PsesLogLevel LogLevel { get; set; } = PsesLogLevel.Warning; /// /// Configuration for the language server protocol transport to use. /// public ITransportConfig LanguageServiceTransport { get; set; } /// /// Configuration for the debug adapter protocol transport to use. /// public ITransportConfig DebugServiceTransport { get; set; } /// /// PowerShell profile locations for Editor Services to use for its profiles. /// If none are provided, these will be generated from the hosting PowerShell's profile paths. /// public ProfilePathConfig ProfilePaths { get; set; } /// /// The InitialSessionState to use when creating runspaces. LanguageMode can be set here. /// public InitialSessionState InitialSessionState { get; internal set; } public string StartupBanner { get; set; } = @" =====> PowerShell Editor Services <===== "; } /// /// Configuration for Editor Services' PowerShell profile paths. /// public struct ProfilePathConfig { /// /// The path to the profile shared by all users across all PowerShell hosts. /// public string AllUsersAllHosts { get; set; } /// /// The path to the profile shared by all users specific to this PSES host. /// public string AllUsersCurrentHost { get; set; } /// /// The path to the profile specific to the current user across all hosts. /// public string CurrentUserAllHosts { get; set; } /// /// The path to the profile specific to the current user and to this PSES host. /// public string CurrentUserCurrentHost { get; set; } } }