예제 #1
0
 public CommandString(ShellCommand Cmd, IEnumerable<string> Prms)
 {
     command = Cmd;
     parameters = new Queue<string>();
     foreach (string s in Prms)
         parameters.Enqueue(s);
 }
예제 #2
0
        public CommandBarControl NewButtonObsolete(IContext context, string caption, int index, string binding, object newItemValue)
        {
            var validValueTypes = new[] { typeof(ScriptBlock), typeof(string) };

            if (null == newItemValue || !validValueTypes.Contains(newItemValue.GetType()))
            {
                var validNames = String.Join(", ", validValueTypes.ToList().ConvertAll(t => t.FullName).ToArray());
                throw new ArgumentException(
                          "new item values for command bar buttons must be one of the following types: " + validNames);
            }



            index = Math.Max(index, 1);
            ShellCommand shellCommand = CommandUtilities.GetOrCreateCommand(
                context,
                _commandBar.Application as DTE2,
                caption,
                newItemValue
                );

            if (!String.IsNullOrEmpty(binding))
            {
                shellCommand.Bindings = new[] { (object)binding };
            }

            Command command = shellCommand.AsCommand();
            var     ctl     = command.AddControl(_commandBar, index) as CommandBarControl;

            return(ctl);
        }
예제 #3
0
        static void Main(string[] args)
        {
            Console.CancelKeyPress += delegate(object sender, ConsoleCancelEventArgs e)
            {
                e.Cancel = true;
            };

            LineEditor lineEditor = new LineEditor();

            lineEditor.LineReceived += delegate(object _, string e)
            {
                if (string.IsNullOrEmpty(e))
                {
                    Console.WriteLine();
                    return;
                }

                ShellCommand     shellCommand     = ParseCommand(e);
                CommandProcessor commandProcessor = new CommandProcessor(shellCommand);

                commandProcessor.Run();
            };

            lineEditor.Start();
        }
        public Task Create(ShellCommand command)
        {
            return new Task(() =>
                {
                    CommandOutput commandOutput;
                    CommandResult output = new CommandResult("", "", "");
                    try
                    {
                        output = this.commandRunner.RunCommand(command);
                        var resultLog = this.logParser.Parse(output.Result);
                        var outputLog = this.logParser.Parse(output.Output);
                        var errorLog = this.logParser.Parse(output.Error);

                        commandOutput = resultLog;
                        commandOutput.Results.AddRange(outputLog.Results);
                        commandOutput.Results.AddRange(errorLog.Results);

                    }
                    catch (Exception ex)
                    {
                        commandOutput = new CommandOutput("goose", "Failed to run command: " + command.Command, ex.ToString(), CommandOutputItemType.Error);
                        output = new CommandResult(commandOutput.ToString(), "", "");
                    }

                    this.errorReporter.Report(command, output);
                    this.outputService.Handle(commandOutput);
                });
        }
예제 #5
0
        /// <summary>
        /// Opens a window with the specified help topic.
        /// </summary>
        /// <param name="topic"></param>
        public static void ShowHelp(Topic topic)
        {
            if (!sTopicMap.TryGetValue(topic, out string fileName))
            {
                Debug.Assert(false, "Unable to find " + topic + " in map");
                return;
            }

            string helpFilePath = Path.Combine(RuntimeDataAccess.GetDirectory(),
                                               HELP_DIR, fileName);

            if (!File.Exists(helpFilePath))
            {
                // Alternate path, used during development.  If it also doesn't exist, leave
                // the original path intact so the error message is useful.
                string altPath = Path.Combine(RuntimeDataAccess.GetDirectory() +
                                              "\\..\\..\\docs\\sgmanual",
                                              fileName);
                altPath = Path.GetFullPath(altPath);    // normalize
                if (File.Exists(altPath))
                {
                    helpFilePath = altPath;
                }
            }
            string url = "file://" + helpFilePath;

            //url = url.Replace("#", "%23");
            Debug.WriteLine("Requesting help URL: " + url);
            ShellCommand.OpenUrl(url);
        }
        public CommandResult RunCommand(ShellCommand command)
        {
            var host = new GoosePSHost();
            var results = new List<string>();
            using (var runspace = RunspaceFactory.CreateRunspace(host))
            {
                var setWorkingDirectory = new Command("set-location");
                setWorkingDirectory.Parameters.Add("path", command.WorkingDirectory);
                var redirectOutput = new Command("out-string");

                runspace.Open();
                var pipeline = runspace.CreatePipeline();
                pipeline.Commands.Add(setWorkingDirectory);
                pipeline.Commands.AddScript(command.Command);
                pipeline.Commands.Add(redirectOutput);

                foreach (var psObject in pipeline.Invoke())
                {
                    var result = FormatCommandResult(psObject);
                    results.Add(result);
                }
                runspace.Close();
            }

            return BuildOutput(results, host);
        }
예제 #7
0
        // IAssembler
        public AssemblerResults RunAssembler(BackgroundWorker worker)
        {
            Debug.Assert(mPathNames.Count == 2);
            string pathName = StripWorkDirectory(mPathNames[0]);
            string cfgName  = StripWorkDirectory(mPathNames[1]);

            AssemblerConfig config =
                AssemblerConfig.GetConfig(AppSettings.Global, AssemblerInfo.Id.Cc65);

            if (string.IsNullOrEmpty(config.ExecutablePath))
            {
                Debug.WriteLine("Assembler not configured");
                return(null);
            }

            string cfgOpt = " -C \"" + cfgName + "\"";

            worker.ReportProgress(0, Properties.Resources.PROGRESS_ASSEMBLING);

            // Wrap pathname in quotes in case it has spaces.
            // (Do we need to shell-escape quotes in the pathName?)
            ShellCommand cmd = new ShellCommand(config.ExecutablePath,
                                                OPTIONS + cfgOpt + " \"" + pathName + "\"", mWorkDirectory, null);

            cmd.Execute();

            // Can't really do anything with a "cancel" request.

            // Output filename is the input filename without the ".S".  Since the filename
            // was generated by us we can be confident in the format.
            string outputFile = mPathNames[0].Substring(0, mPathNames[0].Length - 2);

            return(new AssemblerResults(cmd.FullCommandLine, cmd.ExitCode, cmd.Stdout,
                                        cmd.Stderr, outputFile));
        }
예제 #8
0
        static void Main(string[] args)
        {
            Shell = new Core.ShellShell();
            var cmd = new ShellCommand(CommandNames.Command2, Command1);

            cmd.ConfigureSwitch(SwitchesNames.Switch1);
            cmd.ConfigureParameter(ParameterNames.Parameter1, false);
            cmd.ConfigureParameter(ParameterNames.Parameter2, false, "default1");
            Shell.ConfigureCommand(cmd);

            var cmd2 = new ShellCommand(CommandNames.Command1, Command1);

            cmd2.ConfigureSwitch(SwitchesNames.Switch2);
            cmd2.ConfigureParameter(ParameterNames.Parameter1, true);
            Shell.ConfigureCommand(cmd2);

            Shell.ConfigureGlobalParameter(ParameterNames.Parameter3, true);

            //shell.UseDefaultCommand = true;
            try
            {
                Shell.SetArguments(args);
                Shell.Execute();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.ReadLine();
        }
예제 #9
0
        public void IShellBuilderTest()
        {
            string name    = "My Shell Command";
            string workDir = "/myworkdir";
            string exec1   = "echo hello";
            string exec2   = "echo world";

            IShellCommandBuilder b = new ShellCommandBuilderImpl(_stepsBuilder, _pipelineBuilder);

            b.SetName(name)
            .InDirectory(workDir)
            .Execute(exec1)
            .Execute(exec2)
            .Build();
            ShellCommand actual = (ShellCommand)b.Collect();


            ShellCommand expected = new ShellCommand(name, exec1, exec2);

            expected.WorkDirectory = workDir;


            Assert.AreEqual(expected.WorkDirectory, actual.WorkDirectory);
            Assert.AreEqual(expected.Name, actual.Name);
            Assert.AreEqual(expected.getCommandLines(), actual.getCommandLines());
        }
예제 #10
0
        public void OpenActionKeyword(String actword)
        {
            ProcessStartInfo info;
            var command = actword.Trim();

            command = Environment.ExpandEnvironmentVariables(command);
            var workingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);

            var parts = command.Split(new[] { ' ' }, 2);

            if (parts.Length == 2)
            {
                var filename = parts[0];
                if (ExistInPath(filename))
                {
                    var arguments = parts[1];
                    info = ShellCommand.SetProcessStartInfo(filename, workingDirectory, arguments);
                }
                else
                {
                    info = ShellCommand.SetProcessStartInfo(command, workingDirectory);
                }
            }
            else
            {
                info = ShellCommand.SetProcessStartInfo(command, workingDirectory);
            }
            info.UseShellExecute = true;
            Process.Start(info);
        }
예제 #11
0
        protected override string ProcessChange()
        {
            var recipient = ChatEngine.Owner as IShellCommandRecipient;

            // If there's no target or no recipient, don't bother
            if (!HasAttribute("target") || recipient == null)
            {
                return string.Empty;
            }

            // Build a command
            var name = GetAttribute("command");
            if (name.IsEmpty())
            {
                name = "nav";
            }
            var target = GetAttribute("target");
            var data = GetAttribute("data");

            var command = new ShellCommand(name, target, data);

            // Send the command on to the owner
            var redirect = recipient.ProcessShellCommand(command);

            // If no redirect was specified, use empty otherwise execute a redirect to the result of the star operation
            return !redirect.HasText() ? string.Empty : DoRedirect(redirect);
        }
예제 #12
0
        //todo rewrite this using COM API
        public override StatusResult CheckStatus()
        {
            var    taskName = Params[PARAM_NAME_TASK_NAME];
            string args     = $"schtasks /query /tn \"{taskName}\" /hresult /fo csv /nh";
            var    cmd      = new ShellCommand(args);

            if (cmd.TryExecute(out string taskStatusCSV))
            {
                var actualStatus = taskStatusCSV.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)[0].Split(',')[2]; //{Disabled, Ready}
                var checkStatus  = Params[PARAM_NAME_STATUS];                                                                         // {DISABLED, ENABLED}
                if ((actualStatus.Trim().Trim('"') == "Disabled" && checkStatus == "DISABLED")
                    ||
                    (actualStatus.Trim().Trim('"') == "Ready" && checkStatus == "ENABLED")
                    )
                {
                    return(StatusResult.Match);
                }
                else
                {
                    return(StatusResult.Mismatch);
                }
            }
            else
            {
                return(StatusResult.Unavailable);
            }
        }
예제 #13
0
        //todo rewrite this using COM API
        public override bool Execute()
        {
            var taskName  = Params[PARAM_NAME_TASK_NAME];
            var setStatus = Params[PARAM_NAME_STATUS];// {DISABLED, ENABLED}

            string statusSwitch = null;

            if (setStatus == "DISABLED")
            {
                statusSwitch = "/disable";
            }
            else if (setStatus == "ENABLED")
            {
                statusSwitch = "/enable";
            }
            else
            {
                return(false);
            }

            string args = $"schtasks /change /tn \"{taskName}\" {statusSwitch} /hresult";
            var    cmd  = new ShellCommand(args);

            return(cmd.TryExecute(out _));
        }
        /// <summary>
        /// 执行shell命令
        /// </summary>
        /// <param name="device"></param>
        /// <param name="sh"></param>
        /// <returns></returns>
        public static Tuple <Output, int> Shell(this IDevice device, string sh)
        {
            var cmd    = new ShellCommand(device, sh);
            var result = cmd.Execute();

            return(new Tuple <Output, int>(result.Output, result.ExitCode));
        }
        public static ShellCommand PackageShellCmd()
        {
            ShellCommand packageStep = new ShellCommand("Package TANKS", "mvn package");

            packageStep.WorkDirectory = "./TANKS";

            return(packageStep);
        }
        public static ShellCommand CompileShellCmd()
        {
            ShellCommand compileStep = new ShellCommand("Compile TANKS", "mvn compile");

            compileStep.WorkDirectory = "./TANKS";

            return(compileStep);
        }
        public static ShellCommand GlobalCleanStep()
        {
            ShellCommand cleanStep = new ShellCommand("Compile TANKS", "mvn clean");

            cleanStep.WorkDirectory = "./TANKS";

            return(cleanStep);
        }
        public static ShellCommand InstallShellCmd()
        {
            ShellCommand installStep = new ShellCommand("Install Tanks", "mvn install");

            installStep.WorkDirectory = "./TANKS";

            return(installStep);
        }
        /// <summary>
        /// 获取build.prop中的值
        /// </summary>
        /// <param name="device"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        public static string GetProp(this IDevice device, string key)
        {
            var result = new ShellCommand(device, $"getprop {key}")
                         .Execute()
                         .ThrowIfExitCodeNotEqualsZero();

            return(result.Output.ToString().Trim());
        }
        public void ShellRun(string cmd, string filename = "cmd.exe")
        {
            var args = filename == "cmd.exe" ? $"/C {cmd}" : $"{cmd}";

            var startInfo = ShellCommand.SetProcessStartInfo(filename, arguments: args, createNoWindow: true);

            ShellCommand.Execute(startInfo);
        }
예제 #21
0
        public void GetShellCommandNameTest()
        {
            string name = ShellCommand.GetShellCommandName(typeof(TestCommand));

            Assert.AreEqual("test", name);

            name = ShellCommand.GetShellCommandName(typeof(AnotherCommand));
            Assert.AreEqual("AnotherCommand", name);
        }
예제 #22
0
        public void IsShellCommandTest()
        {
            bool isCommand = ShellCommand.IsShellCommand(typeof(TestCommand));

            Assert.IsTrue(isCommand);

            isCommand = ShellCommand.IsShellCommand(typeof(NotACommand));
            Assert.IsFalse(isCommand);
        }
예제 #23
0
        public void GetShellCommandsTest()
        {
            Type[] commands = ShellCommand.GetShellCommands(Assembly.GetExecutingAssembly());

            Assert.IsNotNull(commands);
            Assert.AreEqual(3, commands.Length);
            CollectionAssert.Contains(commands, typeof(TestCommand));
            CollectionAssert.Contains(commands, typeof(AnotherCommand));
            CollectionAssert.Contains(commands, typeof(CustomParsingCommand));
        }
예제 #24
0
        /// <summary>
        /// 检测某个命令是否存在
        /// </summary>
        /// <param name="device"></param>
        /// <param name="cmd"></param>
        public static void CommandExistsCheck(IDevice device, string cmd)
        {
            var result = new ShellCommand(device, cmd)
                         .Execute();

            if (result.ExitCode == (int)LinuxReturnCode.KeyHasExpired)
            {
                throw new CommandNotFoundException(cmd);
            }
        }
예제 #25
0
        public static bool StartProcess(ShellCommand shellCommand)
        {
            var process = new Process();

            return(StartProcess(new ProcessStartInfo {
                CreateNoWindow = true,
                FileName = shellCommand.FileName,
                Arguments = shellCommand.Args
            }, ref process));
        }
예제 #26
0
        private static void CreateCommand(RegistryKey parentKey, ShellCommand command)
        {
            var shellKey  = parentKey.CreateSubKey(RegistryKeys.Shell);
            var actionKey = shellKey.CreateSubKey(command.Action ?? "open");
            var cmdKey    = actionKey.CreateSubKey(RegistryKeys.Command);

            var cmdStr = $"\"{command.Path}\" \"{command.Argument}\"";

            cmdKey.SetValue(RegistryKeys.Default, cmdStr);
        }
예제 #27
0
        public async Task <int> ExecuteAsync(ShellCommand command)
        {
            Command?cmd = Cli.Wrap(_shell)
                          .WithArguments("/c " + command.Command + " " + command.Arguments)
                          .WithWorkingDirectory(command.WorkDirectory ?? _boostApplicationContext.WorkingDirectory.FullName);

            var exitCode = 0;

            await foreach (CommandEvent? cmdEvent in cmd.ListenAsync())
            {
                switch (cmdEvent)
                {
                case StartedCommandEvent started:
                    _messageHandler?.Invoke(new ShellMessage(
                                                _session.Next(),
                                                "cmd",
                                                $"{_shell}> {command.Command} {command.Arguments}")
                    {
                        Tags = new[] { "command" }
                    });
                    break;

                case StandardOutputCommandEvent stdOut:
                    _messageHandler?.Invoke(new ShellMessage(_session.Next(), "info", stdOut.Text)
                    {
                        Tags = ShellMessageTagger.GetTags(stdOut.Text)
                    });
                    break;

                case StandardErrorCommandEvent stdErr:
                    _messageHandler?.Invoke(new ShellMessage(_session.Next(), "error", stdErr.Text)
                    {
                        Tags = new[] { "error" }
                    });
                    break;

                case ExitedCommandEvent exited:
                    exitCode = exited.ExitCode;
                    _messageHandler?.Invoke(new ShellMessage(
                                                _session.Next(),
                                                "end",
                                                (exitCode == 0) ?
                                                "Command completed successfully" :
                                                $"Command completed with errors (ExitCode: {exitCode})"
                                                )
                    {
                        Tags = new string[] { (exitCode == 0) ? "success" : "error" }
                    });
                    break;
                }
            }

            return(exitCode);
        }
예제 #28
0
        /// <summary>
        /// Define supported shell functions here for use through the game terminal
        /// </summary>
        private void DefineSupportedShellFunctions()
        {
            _supportedShellFunctions = new Dictionary <string, ShellCommand>();

            var helpCmd = new ShellCommand()
            {
                Desc            = "List Supported Commands",
                SupportedInputs = new List <string>()
                {
                    "v - verbose, lists supported inputs for shell functions"
                },
                ShellFunction = ListShellCommands,
            };

            _supportedShellFunctions.Add("help", helpCmd);
            _supportedShellFunctions.Add("?", helpCmd);
            _supportedShellFunctions.Add("q", new ShellCommand()
            {
                Desc          = "Quit Terminal",
                ShellFunction = QuitTerminal
            });
            _supportedShellFunctions.Add("e", new ShellCommand()
            {
                Desc          = "Exit Game",
                ShellFunction = ExitGame
            });
            _supportedShellFunctions.Add("t", new ShellCommand()
            {
                Desc            = "Toggle Specified System",
                SupportedInputs = new List <string>()
                {
                    "fow - fog of war, ai - ai for all npcs"
                },
                ShellFunction = Toggle
            });
            _supportedShellFunctions.Add("ce", new ShellCommand()
            {
                Desc            = "Create Entity",
                SupportedInputs = new List <string>()
                {
                    "marker, seeker, seekerPistol, seekerKnife, seekeraitest, fadingcolor", "x-coord", "y-coord"
                },
                ShellFunction = CreateEntity
            });
            _supportedShellFunctions.Add("le", new ShellCommand()
            {
                Desc            = "List Entities",
                SupportedInputs = new List <string>()
                {
                    "actor"
                },
                ShellFunction = ListEntities
            });
        }
예제 #29
0
 protected override void Run(ShellCommand command, ShellContext context, JobsOptions options)
 {
     foreach (var job in context.Jobs)
     {
         if (options.ShowAll || job.Running)
         {
             var suffix = job.Running ? "running" : "exited";
             Console.WriteLine($"[{job.Id}] - {job.ProcessName} {suffix}");
         }
     }
 }
예제 #30
0
        /// <summary>
        /// Processes a shell command by sending it on to the user interface layer.
        /// </summary>
        /// <param name="command">The command.</param>
        public string ProcessShellCommand(ShellCommand command)
        {
            _alfred.Console?.Log("ShellCommand", "Received shell command: " + command, LogLevel.Info);

            switch (command.Name.ToUpperInvariant())
            {
                case "NAV":
                    return HandleNavigationCommand(command) ? "NAVIGATE SUCCESS" : "NAVIGATE FAILED";
            }

            return string.Empty;
        }
예제 #31
0
        public void StrayexShell_Hello_WriteHello()
        {
            var obj = new ShellCommand("hello", new string[50]);

            if (obj.Interpret())
            {
                return;
            }
            else
            {
                throw new InvalidOperationException("Command Hello not working!");
            }
        }
예제 #32
0
        public void StrayexShell_Echo_WriteEmptyLine()
        {
            var obj = new ShellCommand("echo", new string[50]);

            if (obj.Interpret())
            {
                return;
            }
            else
            {
                throw new InvalidOperationException("Command Echo not working or turned off!");
            }
        }
예제 #33
0
        public void StrayexShell_Clear_ClearConsole()
        {
            var obj = new ShellCommand("clear", new string[50]);

            if (obj.Interpret())
            {
                return;
            }
            else
            {
                throw new InvalidOperationException("Command Clear not working!");
            }
        }
예제 #34
0
        public void Run(ShellCommand command, ShellContext context)
        {
            var builtin = FindBuiltinCommand(command);

            if (builtin is null)
            {
                RunExternalCommand(command, context);
            }
            else
            {
                builtin.Run(command, context);
            }
        }
예제 #35
0
        public void ShellCommandOnlyPipesTest()
        {
            ShellParser         shellParser = MakeParser("git reset --hard | echo");
            ShellCommandContext context     = shellParser.shellCommand();
            ShellVisitor        visitor     = new ShellVisitor();

            ParserResult result       = visitor.Visit(context);
            ShellCommand shellCommand = result.ShellCommandValue;

            result.IsShellCommand.Should().BeTrue();
            shellCommand.IsBackground.Should().BeFalse();
            shellCommand.CommandList.Should().HaveCount(2);
        }
예제 #36
0
        /// <summary>
        /// Processes a shell <paramref name="command"/> by sending it on to the user interface layer.
        /// </summary>
        /// <param name="command">The command.</param>
        /// <returns>The redirect target or string.empty for no redirect.</returns>
        public string ProcessShellCommand(ShellCommand command)
        {
            if (command.Name.Matches("Nav"))
            {
                if (command.Target.Matches("Pages"))
                {
                    // We'll pretend it worked unless the data contained fail. Why not?
                    if (!command.Data.ToUpperInvariant().Contains("FAIL"))
                    {
                        return "Navigate Success";
                    }
                }

                // If we got here, its a navigate and it didn't succeed
                return "Navigate Failed";
            }

            // Default to string.empty
            return string.Empty;
        }
예제 #37
0
        public void ControlCanHandleNavigationCommands()
        {
            Assert.IsNotNull(_app.Alfred.RootPages);

            var lastPage = _app.Alfred.RootPages.LastOrDefault();
            Assert.IsNotNull(lastPage);

            var command = new ShellCommand("Nav", "Pages", lastPage.Id);

            var tab = _control.TabPages;

            Assert.IsNotNull(tab, "TabPages was null");
            Assert.IsTrue(tab.HasItems, "TabPages did not have items");
            var result = _control.HandlePageNavigationCommand(command);

            Assert.IsTrue(result, "Navigation Failed");

            var selectedItem = tab.SelectedItem;
            Assert.IsNotNull(selectedItem, "Selected tab was null after navigate");
            var selectedDomainItem = selectedItem as IAlfredPage;
            Assert.IsNotNull(selectedDomainItem);
            Assert.AreEqual(lastPage.Id, selectedDomainItem.Id, "Selected tab's ID did not match last tab's ID");
        }
        /// <summary>
        ///     Handles the page navigation command.
        /// </summary>
        /// <param name="command">The command.</param>
        /// <returns>Whether or not the command was handled</returns>
        public bool HandlePageNavigationCommand(ShellCommand command)
        {
            if (!command.Data.HasText() || TabPages == null) { return false; }

            return SelectionHelper.SelectItemById(TabPages, command.Data);
        }
예제 #39
0
 /// <summary>
 ///     Handles the page navigation <paramref name="command" /> .
 /// </summary>
 /// <param name="command">The command.</param>
 /// <returns>Whether or not the <paramref name="command"/> was handled</returns>
 public bool HandlePageNavigationCommand(ShellCommand command)
 {
     Debug.Assert(PagesControl != null);
     return PagesControl.HandlePageNavigationCommand(command);
 }
예제 #40
0
 protected bool Equals(ShellCommand other)
 {
     return string.Equals(WorkingDirectory, other.WorkingDirectory) && string.Equals(Command, other.Command);
 }
예제 #41
0
        public string GetHelpText(ShellCommand cmd)
        {
            string helpText = String.Empty;
            switch (cmd)
            {
                case ShellCommand.None:
                    helpText =
            @"This system recognizes the following commands:
            LIST, CLEAR, EDIT, PROMOTE, DEMOTE, DELETE, REGISTERS, LOG
            Type HELP [COMMAND] for more information on a system command.";
                    break;
                case ShellCommand.Clear:
                    helpText =
            @"Clear Command
            Syntax: CLEAR
            This command will flush the terminal display buffers.";
                    break;
                case ShellCommand.Delete:
                    helpText =
            @"Delete Command
            Syntax: DELETE [PROGRAM]
            This command will remove a program from system memory.";
                    break;
                case ShellCommand.Demote:
                    helpText =
            @"Demote Command
            Syntax: DEMOTE [PROGRAM]
            This command will lower a program's run priority.";
                    break;
                case ShellCommand.Edit:
                    helpText =
            @"Edit Command
            Syntax: EDIT [PROGRAM]
            This command will edit the program provided as a parameter.
            If the program does not exist it will be created.";
                    break;
                case ShellCommand.Help:
                    helpText =
            @"Help Command
            Syntax: HELP *[PROGRAM]
            This command will display general help information on this system.
            The optional program parameter will provide more specific information.";
                    break;
                case ShellCommand.List:
                    helpText =
            @"List Command
            Syntax: LIST
            This command lists all programs in resident memory in
            descending order of run priority.";
                    break;
                case ShellCommand.Promote:
                    helpText =
            @"Promote Command
            Syntax: PROMOTE [PROGRAM]
            This command will raise the run priority of the program
            provided as a parameter.";
                    break;
                case ShellCommand.Registers:
                    helpText =
            @"Registers Command
            Syntax: REGISTERS
            This command will display the current status of all system
            memory registers.

            Reserved Registers
            ------------------
            99: Thermostat reading
            98: HVAC On/Off setting
            97: Heater/Condenser setting";
                    break;
                case ShellCommand.Log:
                    helpText =
            @"Log Command
            Syntax: LOG
            This command will log program execution and resulting errors.";
                    break;
                case ShellCommand.Notes:
                    /*helpText =
            @"Registers Command
            Syntax: REGISTERS
            This command will display the current status of all system
            memory registers.";*/
                    break;
            }
            return helpText;
        }
예제 #42
0
        public string ProcessShellCommand(ShellCommand command)
        {
            // Commands are very, very important and need to be logged.
            Alfred?.Console?.Log(Resources.AlfredCommandRouterProcessShellCommandLogHeader,
                                 string.Format(CultureInfo.CurrentCulture,
                                               Resources.AlfredCommandRouterProcessShellCommandMessage,
                                               command.Name,
                                               command.Target,
                                               command.Data),
                                 LogLevel.Info);

            var shell = Alfred?.ShellCommandHandler;

            var result = shell?.ProcessShellCommand(command);

            return result.NonNull();
        }
예제 #43
0
 public void ControlDoesNotHandleBogusCommands()
 {
     var command = new ShellCommand("Nav", "Pages", "IamTheBatman");
     var result = _control.HandlePageNavigationCommand(command);
     Assert.IsFalse(result);
 }
예제 #44
0
 public PowerShellGooseAction(IPowerShellTaskFactory powershellTaskFactory, ShellCommand command)
 {
     this.powershellTaskFactory = powershellTaskFactory;
     this.command = command;
 }
예제 #45
0
        /// <summary>
        /// Handles a shell navigation command.
        /// </summary>
        /// <param name="command">The command.</param>
        /// <returns>Whether or not the event was handled</returns>
        private bool HandleNavigationCommand(ShellCommand command)
        {
            switch (command.Target.ToUpperInvariant())
            {
                case "PAGES":
                    return _uiDirector.HandlePageNavigationCommand(command);
            }

            return false;
        }