Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Ask for target directory when using create-project #9181

Merged
merged 1 commit into from Sep 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/03-cli.md
Expand Up @@ -748,6 +748,7 @@ By default the command checks for the packages on packagist.org.
* **--ignore-platform-req:** ignore a specific platform requirement(`php`,
`hhvm`, `lib-*` and `ext-*`) and force the installation even if the local machine
does not fulfill it.
* **--ask:** Ask user to provide target directory for new project.

## dump-autoload (dumpautoload)

Expand Down
5 changes: 5 additions & 0 deletions src/Composer/Command/CreateProjectCommand.php
Expand Up @@ -84,6 +84,7 @@ protected function configure()
new InputOption('no-install', null, InputOption::VALUE_NONE, 'Whether to skip installation of the package dependencies.'),
new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
new InputOption('ask', null, InputOption::VALUE_NONE, 'Whether to ask for project directory.'),
))
->setHelp(
<<<EOT
Expand Down Expand Up @@ -130,6 +131,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
$input->setOption('no-plugins', true);
}

if ($input->isInteractive() && $input->getOption('ask')) {
$input->setArgument('directory', $io->ask('New project directory <comment>[optional]</comment>: '));
}

$ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);

return $this->installProject(
Expand Down