Omnishell/GetPromptCmd.cs
using Core;
using System; using System.IO; using System.Management.Automation; using System.Reflection; namespace Module; [Cmdlet(VerbsCommon.Get, "Prompt")] [OutputType(typeof(string))] public class GetPromptCmd : PSCmdlet { private static IOmnishell _omnishell; private static IPSContext _context; public GetPromptCmd() { if (_omnishell == null) { _omnishell = OmnishellFactory<ModuleConfiguration>.Build<IOmnishell>(); _context = OmnishellFactory<ModuleConfiguration>.Build<IPSContext>(); ConfigFile.SetupConfigFile(); } } protected override void BeginProcessing() { _context.Host = Host; _context.WorkingDir = SessionState.Path.CurrentFileSystemLocation.Path; } protected override void ProcessRecord() { WriteObject(_omnishell.PrintPrompt()); } } |