public function initialize(ConsoleEvent $event)
    {
        $command = $event->getCommand();

        if (!$command instanceof InitCommand) {
            return;
        }

        if (!$this->gitHelper->isGitDir()) {
            throw new UserException(
                sprintf(
                    'You can only run the "%s" command when you are in a Git directory.',
                    $command->getName()
                )
            );
        }

        $input = $event->getInput();

        $input->setOption(
            'repo-adapter',
            GitHelper::undefinedToDefault($input->getOption('repo-adapter'), $this->detectAdapterName())
        );

        $input->setOption(
            'issue-adapter',
            GitHelper::undefinedToDefault(
                $input->getOption('issue-adapter'),
                $input->getOption('repo-adapter')
            )
        );

        if (!$this->application->getAdapterFactory()->supports($input->getOption('repo-adapter'), AdapterFactory::SUPPORT_REPOSITORY_MANAGER)) {
            return;
        }

        $org = GitHelper::undefinedToDefault($input->getOption('org'));
        $repo = GitHelper::undefinedToDefault($input->getOption('repo'));

        if (null === $org || null === $repo) {
            list($org, $repo) = $this->getRepositoryReference(
                $this->getAdapter($input->getOption('repo-adapter')),
                $org,
                $repo
            );

            if (!$input->isInteractive()) {
                $this->styleHelper->note(
                    [
                        'You did not provide an organization and/or repository name.',
                        'Gush automatically detected the missing information.',
                        sprintf('Org: "%s" / repo: "%s"', $org, $repo),
                    ]
                );
            }

            $input->setOption('org', $org);
            $input->setOption('repo', $repo);
        }

        $input->setOption('issue-org', GitHelper::undefinedToDefault($input->getOption('issue-org'), $org));
        $input->setOption('issue-project', GitHelper::undefinedToDefault($input->getOption('issue-project'), $repo));
    }
public function initialize(ConsoleEvent $event)
    {
        $command = $event->getCommand();

        if (!$command instanceof InitCommand) {
            return;
        }

        if (!$this->gitHelper->isGitDir()) {
            throw new UserException(
                sprintf(
                    'You can only run the "%s" command when you are in a Git directory.',
                    $command->getName()
                )
            );
        }

        $input = $event->getInput();

        $input->setOption(
            'repo-adapter',
            GitHelper::undefinedToDefault($input->getOption('repo-adapter'), $this->detectAdapterName())
        );

        $input->setOption(
            'issue-adapter',
            GitHelper::undefinedToDefault(
                $input->getOption('issue-adapter'),
                $input->getOption('repo-adapter')
            )
        );

        if (!$this->application->getAdapterFactory()->supports($input->getOption('repo-adapter'), AdapterFactory::SUPPORT_REPOSITORY_MANAGER)) {
            return;
        }

        $org = GitHelper::undefinedToDefault($input->getOption('org'));
        $repo = GitHelper::undefinedToDefault($input->getOption('repo'));

        if (null === $org || null === $repo) {
            list($org, $repo) = $this->getRepositoryReference(
                $this->getAdapter($input->getOption('repo-adapter')),
                $org,
                $repo
            );

            if (!$input->isInteractive()) {
                $this->styleHelper->note(
                    [
                        'You did not provide an organization and/or repository name.',
                        'Gush automatically detected the missing information.',
                        sprintf('Org: "%s" / repo: "%s"', $org, $repo),
                    ]
                );
            }

            $input->setOption('org', $org);
            $input->setOption('repo', $repo);
        }

        $input->setOption('issue-org', GitHelper::undefinedToDefault($input->getOption('issue-org'), $org));
        $input->setOption('issue-project', GitHelper::undefinedToDefault($input->getOption('issue-project'), $repo));
    }
public function initialize ( ConsoleEvent $ event ) { $ command = $ event -> getCommand ( ) ; if ( ! $ command instanceof InitCommand ) { return ; } if ( ! $ this -> gitHelper -> isGitDir ( ) ) { throw new UserException ( sprintf ( 'You can only run the "%s" command when you are in a Git directory.' , $ command -> getName ( ) ) ) ; } $ input = $ event -> getInput ( ) ; $ input -> setOption ( 'repo-adapter' , GitHelper :: undefinedToDefault ( $ input -> getOption ( 'repo-adapter' ) , $ this -> detectAdapterName ( ) ) ) ; $ input -> setOption ( 'issue-adapter' , GitHelper :: undefinedToDefault ( $ input -> getOption ( 'issue-adapter' ) , $ input -> getOption ( 'repo-adapter' ) ) ) ; if ( ! $ this -> application -> getAdapterFactory ( ) -> supports ( $ input -> getOption ( 'repo-adapter' ) , AdapterFactory :: SUPPORT_REPOSITORY_MANAGER ) ) { return ; } $ org = GitHelper :: undefinedToDefault ( $ input -> getOption ( 'org' ) ) ; $ repo = GitHelper :: undefinedToDefault ( $ input -> getOption ( 'repo' ) ) ; if ( null === $ org || null === $ repo ) { list ( $ org , $ repo ) = $ this -> getRepositoryReference ( $ this -> getAdapter ( $ input -> getOption ( 'repo-adapter' ) ) , $ org , $ repo ) ; if ( ! $ input -> isInteractive ( ) ) { $ this -> styleHelper -> note ( [ 'You did not provide an organization and/or repository name.' , 'Gush automatically detected the missing information.' , sprintf ( 'Org: "%s" / repo: "%s"' , $ org , $ repo ) , ] ) ; } $ input -> setOption ( 'org' , $ org ) ; $ input -> setOption ( 'repo' , $ repo ) ; } $ input -> setOption ( 'issue-org' , GitHelper :: undefinedToDefault ( $ input -> getOption ( 'issue-org' ) , $ org ) ) ; $ input -> setOption ( 'issue-project' , GitHelper :: undefinedToDefault ( $ input -> getOption ( 'issue-project' ) , $ repo ) ) ; }
Use this for detecting the org and repo.

Add the options to decorateDefinition.

@param ConsoleEvent $event
Use this for detecting the org and repo .