public static Shell AddCommand(this Shell shell, string pattern, string description, InvokeShellCommandDelegate invokeHandler, CompleteShellCommandDelegate completeHandler) { if (shell == null) { throw new ArgumentNullException(nameof(shell)); } if (invokeHandler == null) { throw new ArgumentNullException(nameof(invokeHandler)); } var command = new ShellCommand(pattern, description); command.InvokeCommand += (sender, args) => { invokeHandler(args.Shell, sender as IShellCommand, args.Arguments); }; if (completeHandler != null) { command.CompleteCommand += (sender, args) => { args.Result = completeHandler(args.Shell, sender as IShellCommand, args.Tokens); }; } return(shell.AddCommand(command)); }
private static void RegisterCommands(Shell shell, bool interactive) { if (interactive) { shell.AddCommand("exit", "Exit from program", Exit); shell.AddCommand("quit", "Exit from program", Exit); } shell.AddCommand(new HelpShellCommand()); shell.AddCommand("options", "Test options", InvokeTestOptions); shell.AddCommand(new FakeShellCommand("sip list", "list sip peers")); shell.AddCommand(new FakeShellCommand("sip add", "add sip peer")); shell.AddCommand(new FakeShellCommand("sip delete", "delete sip peer")); shell.AddCommand(new FakeShellCommand("sip acl list")); shell.AddCommand(new FakeShellCommand("sip acl add")); shell.AddCommand(new FakeShellCommand("sip acl delete")); shell.AddCommand(new FakeShellCommand("sip acl stick")); shell.AddCommand(new FakeShellCommand("sip acl flush")); shell.AddCommand(new FakeShellCommand("ip show")); shell.AddCommand(new CompleteMultipleFakeShellCommand("list")); shell.AddCommand(new CompleteOneFakeShellCommand("show")); shell.AddCommand(new AdditionalInputShellCommand()); }
public static Shell AddCommand(this Shell shell, string pattern, InvokeShellCommandDelegate invokeHandler) { return(shell.AddCommand(pattern, invokeHandler, null)); }