예제 #1
0
 public Bot(IStartCommand startCommand, IEnterSignInDataCommand enterSignInDataCommand,
            IShowDirsCommand showDirsCommand, IPingCommand pingCommand,
            IIfConfingCommand ifConfingCommand, IMonitorModeCommand monitorModeCommand,
            IAllWifiInterception allWifiInterception, ISendPackagesCommand sendPackagesCommand,
            ICDCommand cDCommand, IBackCDCommand backCDCommand, IPWDCommand pWDCommand,
            IAirCrackNgCommand airCrackNgCommand, INetDiscoverCommand netDiscover,
            INmapCommand nmapCommand, ISMTPUserCheckCommand sMTPUserCheckCommand,
            IHelpCommand helpCommand, ISSHBruteForceCommand sSHBruteForceCommand,
            ISSHConnectCommand sSHConnectCommand)
 {
     _startCommand           = startCommand ?? throw new ArgumentNullException(nameof(startCommand), " was null");
     _enterSignInDataCommand = enterSignInDataCommand ?? throw new ArgumentNullException(nameof(enterSignInDataCommand), " was null");
     _showDirsCommand        = showDirsCommand ?? throw new ArgumentNullException(nameof(showDirsCommand), " was null");
     _pingCommand            = pingCommand ?? throw new ArgumentNullException(nameof(pingCommand), " was null");
     _ifConfigCommand        = ifConfingCommand ?? throw new ArgumentNullException(nameof(ifConfingCommand), " was null");
     _monitorModeCommand     = monitorModeCommand ?? throw new ArgumentNullException(nameof(monitorModeCommand), " was null");
     _allWifiInterception    = allWifiInterception ?? throw new ArgumentNullException(nameof(allWifiInterception), " was null");
     _sendPackagesCommand    = sendPackagesCommand ?? throw new ArgumentNullException(nameof(sendPackagesCommand), " was null");
     _cDCommand            = cDCommand ?? throw new ArgumentNullException(nameof(cDCommand), " was null");
     _backCDCommand        = backCDCommand ?? throw new ArgumentNullException(nameof(backCDCommand), " was null");
     _pWDCommand           = pWDCommand ?? throw new ArgumentNullException(nameof(pWDCommand), " was null");
     _airCrackNgCommand    = airCrackNgCommand ?? throw new ArgumentNullException(nameof(airCrackNgCommand), " was null");
     _netDiscoverCommand   = netDiscover ?? throw new ArgumentNullException(nameof(netDiscover), " was null.");
     _nmapCommand          = nmapCommand ?? throw new ArgumentNullException(nameof(nmapCommand), " was null.");
     _sMTPUserCheckCommand = sMTPUserCheckCommand ?? throw new ArgumentNullException(nameof(sMTPUserCheckCommand), " was null.");
     _helpCommand          = helpCommand ?? throw new ArgumentNullException(nameof(helpCommand), " was null.");
     _sSHBruteForceCommand = sSHBruteForceCommand ?? throw new ArgumentNullException(nameof(sSHBruteForceCommand), " was null.");
     _sSHConnectCommand    = sSHConnectCommand ?? throw new ArgumentNullException(nameof(sSHConnectCommand), " was null.");
 }
예제 #2
0
 public Controller(IExitCommand exitCommand,
                   IHelpCommand helpCommand,
                   ICd cdCommand,
                   IDirCommand dirCommand,
                   IInitCommand initComman,
                   IStatusCommand statusCommand,
                   IListCommand listCommand,
                   IRegisterCommand registerCommand,
                   ILoginCommand logInCommand,
                   IAddCommand addCommand,
                   IRemoveCommand removeCommand,
                   ITestHttp testHttp, ICommitCommand commitCommand)
 {
     this.exitCommand     = exitCommand;
     this.helpCommand     = helpCommand;
     this.cdCommand       = cdCommand;
     this.dirCommand      = dirCommand;
     this.initComman      = initComman;
     this.statusCommand   = statusCommand;
     this.listCommand     = listCommand;
     this.registerCommand = registerCommand;
     this.loginCommand    = logInCommand;
     this.addCommand      = addCommand;
     this.removeCommand   = removeCommand;
     this.testHttp        = testHttp;
     this.commitCommand   = commitCommand;
 }
예제 #3
0
        public Program(ApplicationInformation applicationInformation, IUserInterface userInterface, IActionLogger logger, ICommandLineArgumentInterpreter commandLineArgumentInterpreter, IHelpCommand helpCommand)
        {
            if (applicationInformation == null)
            {
                throw new ArgumentNullException("applicationInformation");
            }

            if (userInterface == null)
            {
                throw new ArgumentNullException("userInterface");
            }

            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }

            if (commandLineArgumentInterpreter == null)
            {
                throw new ArgumentNullException("commandLineArgumentInterpreter");
            }

            if (helpCommand == null)
            {
                throw new ArgumentNullException("helpCommand");
            }

            this.applicationInformation = applicationInformation;
            this.userInterface = userInterface;
            this.logger = logger;
            this.commandLineArgumentInterpreter = commandLineArgumentInterpreter;
            this.helpCommand = helpCommand;
        }
예제 #4
0
        public void BeforeEachTest()
        {
            this.sequentialTestExecutionMonitor.WaitOne();

            CommandLineIntegrationTestUtilities.RemoveAllFilesAndFoldersWhichAreCreatedOnStartup();

            StructureMapSetup.Setup();
            this.encodingProvider = ObjectFactory.GetInstance<IEncodingProvider>();
            this.applicationInformation = ObjectFactory.GetInstance<ApplicationInformation>();
            this.commandProvider = ObjectFactory.GetInstance<ICommandProvider>();
            this.userInterface = ObjectFactory.GetInstance<IUserInterface>();
            this.logger = ObjectFactory.GetInstance<IActionLogger>();
            this.commandLineArgumentInterpreter = ObjectFactory.GetInstance<ICommandLineArgumentInterpreter>();
            this.helpCommand = ObjectFactory.GetInstance<IHelpCommand>();

            this.program = new Program(this.applicationInformation, this.userInterface, this.logger, this.commandLineArgumentInterpreter, this.helpCommand);
        }
예제 #5
0
        public RaidDispatcher(
            IStartCommand startGroupCommand,
            // IConfigureUserCommand startPrivatCommand,
            IHelpCommand helpCommand,
            ICancelCommand cancelCommand,
            IPollAnswer raidPollAnswer,
            ISettingsCommand settingsCommand,
            // ICreateRaidCommand createRaidCommand,
            IIvCommand ivCommand,
            IPokeCommand pokeCommand,
            IGymsCommand gymsCommand,
            MemberRemoved memberRemoved,
            MembersAdded memberAdded,
            IOwnerCommand ownerCommand,
            IUpdateRaidBossCommand updateRaidBossCommand
            )
        {
            this.commands.Add(startGroupCommand);
            // this.commands.Add(startPrivatCommand);
            this.commands.Add(helpCommand);
            this.commands.Add(cancelCommand);

            this.answers.Add(raidPollAnswer);
            this.commands.Add(settingsCommand);
            // this.commands.Add(createRaidCommand);
            this.commands.Add(ivCommand);
            this.commands.Add(gymsCommand);
            this.commands.Add(pokeCommand);
            this.commands.Add(ownerCommand);
            this.commands.Add(updateRaidBossCommand);


            this.memberAdded   = memberAdded;
            this.memberRemoved = memberRemoved;

            helpCommand.RegisterAllCommands(this.commands.Select(x => x.Value).ToList());
        }
        public static int DispatchCommand(IList<IConsoleCommand> commands, string[] arguments, TextWriter consoleOut,
            bool skipExeInExpectedUsage = false, IHelpCommand customHelpCommand = null, bool globallyDisableTraceCommandAfterParse = false)
        {
            if (customHelpCommand != null)
            {
                customHelpCommand.SkipExeInExpectedUsage = skipExeInExpectedUsage;
            }

            IConsoleCommand selectedCommand = null;

            var console = consoleOut;

            foreach (var command in commands)
            {
                ValidateConsoleCommand(command);
            }

            try
            {
                List<string> remainingArguments;

                if (commands.Count == 1)
                {
                    selectedCommand = commands.First();
                    // support basic splitting of command arguments like "q|quit" => q, quit
                    if (arguments.Any() && ConsoleUtil.DoesArgMatchCommand(arguments.First(), selectedCommand))
                    {
                        remainingArguments = selectedCommand.GetActualOptions().Parse(arguments.Skip(1));
                    }
                    else
                    {
                        remainingArguments = selectedCommand.GetActualOptions().Parse(arguments);
                    }
                }
                else
                {
                    if (!arguments.Any())
                        throw new ConsoleHelpAsException("No arguments specified.");

                    // to support custom help implementation
                    if (customHelpCommand != null &&
                        ConsoleUtil.DoesArgMatchCommand(arguments.First(), customHelpCommand))
                    {
                        customHelpCommand.HelpExplicitlyCalled = true;
                        var helpRemainingArgs = new string[0];
                        try
                        {
                            helpRemainingArgs = customHelpCommand.GetActualOptions().Parse(arguments.Skip(1)).ToArray();
                        }
                        catch
                        {
                            // ignore parsing errors for help command
                        }
                        return customHelpCommand.Run(helpRemainingArgs);
                    }

                    if (arguments.First().Equals("help", StringComparison.InvariantCultureIgnoreCase))
                    {
                        selectedCommand = GetMatchingCommand(commands.Where(it => !it.IsHidden).ToList(),
                            arguments.Skip(1).FirstOrDefault()); // excude hidden commands from help mechanism

                        if (selectedCommand == null)
                        {
                            ConsoleHelp.ShowSummaryOfCommands(commands, console);
                        }
                        else
                        {
                            ConsoleHelp.ShowCommandHelp(selectedCommand, console, skipExeInExpectedUsage);
                        }
                        return -1;
                    }

                    selectedCommand = GetMatchingCommand(commands, arguments.First());

                    if (selectedCommand == null)
                        throw new ConsoleHelpAsException("Command name not recognized.");

                    remainingArguments = selectedCommand.GetActualOptions().Parse(arguments.Skip(1));
                }

                selectedCommand.CheckRequiredArguments();

                selectedCommand.CheckSubLevelArguments(arguments.Skip(1).ToArray());

                CheckRemainingArguments(remainingArguments, selectedCommand.RemainingArgumentsCount);

                var preResult = selectedCommand.OverrideAfterHandlingArgumentsBeforeRun(remainingArguments.ToArray());

                if (preResult.HasValue)
                    return preResult.Value;

                if (!globallyDisableTraceCommandAfterParse)
                {
                    ConsoleHelp.ShowParsedCommand(selectedCommand, console);
                }

                return selectedCommand.Run(remainingArguments.ToArray());
            }
            catch (Exception e)
            {
                if (e is ConsoleHelpAsException || e is OptionException)
                {
                    if (customHelpCommand != null)
                    {
                        customHelpCommand.FailureReason = e;
                        // also use OverrideAfterHandlingArgumentsBeforeRun mechanism for help command
                        var remainingArguments = new string[0];
                        try
                        {
                            remainingArguments = customHelpCommand.GetActualOptions().Parse(arguments).ToArray();

                        } catch {
                            // ignore parsing errors for help command
                        }

                        var preResult = customHelpCommand.OverrideAfterHandlingArgumentsBeforeRun(remainingArguments);
                        if (preResult.HasValue)
                            return preResult.Value;

                        // also show manyconsole exception message
                        console.WriteLine();
                        console.WriteLine(e.Message);
                        
                        return customHelpCommand.Run(remainingArguments);
                    }
                    return DealWithException(e, console, skipExeInExpectedUsage, selectedCommand, commands);
                }
                throw;
            }
        }
        public ConsoleCommandProvider(InstallationStatusCommand installationStatus, InstallCommand install, UninstallCommand uninstall, CleanupCommand cleanup, PackageSolutionCommand packageSolution, PackageBuildOutputCommand packageBuildOutput, RepositorySourceConfigurationCommand configureSources, PublishingTargetConfigurationCommand configurePublishingTargets, SelfUpdateCommand selfUpdate, PublishCommand publishCommand, IHelpCommand helpCommand)
        {
            if (installationStatus == null)
            {
                throw new ArgumentNullException("installationStatus");
            }

            if (install == null)
            {
                throw new ArgumentNullException("install");
            }

            if (uninstall == null)
            {
                throw new ArgumentNullException("uninstall");
            }

            if (cleanup == null)
            {
                throw new ArgumentNullException("cleanup");
            }

            if (packageSolution == null)
            {
                throw new ArgumentNullException("packageSolution");
            }

            if (packageBuildOutput == null)
            {
                throw new ArgumentNullException("packageBuildOutput");
            }

            if (configureSources == null)
            {
                throw new ArgumentNullException("configureSources");
            }

            if (configurePublishingTargets == null)
            {
                throw new ArgumentNullException("configurePublishingTargets");
            }

            if (selfUpdate == null)
            {
                throw new ArgumentNullException("selfUpdate");
            }

            if (publishCommand == null)
            {
                throw new ArgumentNullException("publishCommand");
            }

            if (helpCommand == null)
            {
                throw new ArgumentNullException("helpCommand");
            }

            this.commands = new List<ICommand>
                {
                    installationStatus,
                    install,
                    uninstall,
                    cleanup,
                    packageSolution,
                    packageBuildOutput,
                    configureSources,
                    configurePublishingTargets,
                    selfUpdate,
                    publishCommand,
                    helpCommand
                };
        }