Adds a command to the library

@return Application
344
public function add($command)
    {
        $tasks = $this->prepper
                    ->load(get_class($command))
                    ->describe();

        $this->library->add(['task' => $tasks, 'class' => $command]);

        return $this;
    }
692444
protected function startCommandsPlugin($app)
    {
        $this->onRegister('commands', function ($app) {
            /** @var \Illuminate\Foundation\Application $app */
            // Commands
            if ($app->runningInConsole()) {
                foreach ($this->findCommands as $path) {
                    $dir = path_get_directory((new ReflectionClass(get_called_class()))->getFileName());
                    $classes = $this->findCommandsIn(path_join($dir, $path), $this->findCommandsRecursive);

                    $this->commands = array_merge($this->commands, $classes);
                }
                if (is_array($this->commands) && count($this->commands) > 0) {
                    $commands = [];
                    foreach ($this->commands as $k => $v) {
                        if (is_string($k)) {
                            $app[ $this->commandPrefix.$k ] = $app->share(function ($app) use ($k, $v) {
                                return $app->build($v);
                            });

                            $commands[] = $this->commandPrefix.$k;
                        } else {
                            $commands[] = $v;
                        }
                    }
                    $this->commands($commands);
                }
            }
        });
    }
343339
private function createCommandHandler()
    {
        return function (CommandInterface $command) {
            return Promise\coroutine(function () use ($command) {
                // Prepare the HTTP options.
                $opts = $command['@http'] ?: [];
                unset($command['@http']);

                try {
                    // Prepare the request from the command and send it.
                    $request = $this->transformCommandToRequest($command);
                    $promise = $this->httpClient->sendAsync($request, $opts);

                    // Create a result from the response.
                    $response = (yield $promise);
                    yield $this->transformResponseToResult($response, $request, $command);
                } catch (\Exception $e) {
                    throw CommandException::fromPrevious($command, $e);
                }
            });
        };
    }
687917
public function addToolbarCommands()
    {
        $actor = $this->getController()->getItem();
        $viewer = get_viewer();
        $this->_use_post = true;
        $this->addListCommands();

        if ($actor->authorize('administration')) {
            $this->addCommand('edit-actor', array('label' => AnTranslator::_('LIB-AN-ACTION-EDIT'), 'entity' => $actor))
            ->getCommand('edit-actor')
            ->href($actor->getURL().'&get=settings');
        }

        if (get_viewer()->admin()) {
            $action = ($actor->verified) ? 'unverify' : 'verify';
            $this->addCommand($action.'-actor', array('label' => AnTranslator::_('COM-ACTORS-PROFILE-'.$action), 'entity' => $actor))
            ->getCommand($action.'-actor')
            ->href($actor->getURL().'&action='.$action)
            ->dataTrigger('PostLink');
        }

        if ($actor->authorize('changeEnabled')) {
            $action = ($actor->enabled) ? 'disable' : 'enable';
            $this->addCommand($action.'-actor', array('label' => AnTranslator::_('LIB-AN-ACTION-'.$action), 'entity' => $actor))
            ->getCommand($action.'-actor')
            ->href($actor->getURL().'&action='.$action)
            ->dataTrigger('PostLink');
        }

        if ($actor->authorize('access') && !$viewer->eql($actor) && $viewer->following($actor)) {
            $this->addCommand('notifications-settings', array('label' => AnTranslator::_('COM-ACTORS-NOTIFICATIONS-SETTING-EDIT')))
            ->getCommand('notifications-settings')
            ->href(route('option=notifications&view=settings&layout=modal&oid='.$actor->id));
        }
    }
14772
protected function registerAppContainerCommand($command)
    {
        $this->app->singleton($command, function ($app) {
            return new Commands\AppContainerCommand($app);
        });
    }
955511
public function registerCommands()
    {
        $this->app['command.cpanel.install'] = $this->app->share(function()
        {
            return new InstallCommand();
        });

        $this->app['command.cpanel.user'] = $this->app->share(function()
        {
            return new UserSeedCommand();
        });

        $this->commands('command.cpanel.install','command.cpanel.user');
    }
646779
private function createFromCommand()
    {
        $command = TagCommand::getInstance($this->getRepository())->listTags();
        $outputLines = $this->getCaller()->execute($command, true, $this->getRepository()->getPath())->getOutputLines();
        $this->parseOutputLines($outputLines);
    }
892164
public function addToolbarCommands()
    {
        $entity = $this->getController()->getItem();

        if ($entity->authorize('vote')) {
            $this->addCommand('vote');
        }

        if ($entity->owner->authorize('administration')) {
            $this->addCommand('OpenSetSelector', AnTranslator::_('COM-PHOTOS-ACTION-ADD-TO-SET'))
                ->getCommand('OpenSetSelector')
                ->href(route('option=com_photos&view=sets&layout=selector&oid='.$entity->owner->id.'&photo_id='.$entity->id))
                ->class('visible-desktop');

            $this->addAdministrationCommands();
        }

        if ($entity->authorize('subscribe') || $entity->subscribed(get_viewer())) {
            $this->addCommand('subscribe');
        }

        if ($entity->authorize('delete')) {
            $this->addCommand('delete');
        }
    }
421759
public function add(SymfonyCommand $command)
    {
        if ($command instanceof Command) {
            $command->setContainer($this->container);
        }

        return $this->addToParent($command);
    }
642898
public function addCommand(Command $command) {
        $this->commands[$command->getName()] = $command;
        $command->freeze();
        return $this;
    }
972075
public function register(Application $App) {
        $App->addCommand(new \YourApp\Command\Foo());
        $App->addCommand(new \YourApp\Command\Bar());
        $App->addCommand(new \YourApp\Command\Baz());
    }
239752
private function registerListenerMakeCommand()
    {
        $this->app->bindShared('command.make.package.listener', function ($app)
        {
            return new ListenerMakeCommand($app['files'], $app['packages']);
        });

        $this->commands('command.make.package.listener');
    }
1083370
protected function buildCommand()
    {
        $command = new Command(\Tivie\Command\ESCAPE);
        $command
            ->setCommand('top')
            ->addArgument(new Argument('-b'))
            ->addArgument(new Argument('-n', 1));

        return $command;
    }
237434
public function run()
    {
        if ($this->app->getName()) {
            $this->output->writeln($this->app->getName());
            $this->output->newline();
        }

        $commandName = $this->parameter->getArgument('command_name');

        if ($this->parameter->getCommandName() === $this->name && $commandName) {
            $this->showCommandHelp($this->parameter->getArgument('command_name'));
        } else {
            $this->showGeneralHelp();
        }

        return $this;
    }
551186
public function addCommand($command, $config = array())
    {
        if (! ($command instanceof  AnControllerToolbarCommand)) {
            $command = $this->getCommand($command, $config);
        }

        $this->_commands[$command->getName()] = $command;
        return $this;
    }
517125
public function addCommand($command)
    {
        $command = $this->resolveCommandObject($command);

        /*
         * At this stage we definitely have a proper command to use.
         *
         * @var Command $command
         */
        $this->commands[$command->getName()] = $command;

        $aliases = $command->getAliases();

        if (empty($aliases)) {
            return $this;
        }

        foreach ($command->getAliases() as $alias) {
            if (isset($this->commands[$alias])) {
                throw new TelegramSDKException(sprintf(
                    '[Error] Alias [%s] conflicts with command name of "%s" try with another name or remove this alias from the list.',
                    $alias,
                    get_class($command)
                ));
            }

            if (isset($this->commandAliases[$alias])) {
                throw new TelegramSDKException(sprintf(
                    '[Error] Alias [%s] conflicts with another command\'s alias list: "%s", try with another name or remove this alias from the list.',
                    $alias,
                    get_class($command)
                ));
            }

            $this->commandAliases[$alias] = $command;
        }

        return $this;


    }
59422
protected function createApplication()
    {
        putenv('APP_ENV=' . $this->getEnv());

        $app = require $this->appPath;

        $app->make(Kernel::class)->bootstrap();

        Carbon::setTestNow(Carbon::now());

        return $app;
    }