|
17 | 17 |
|
18 | 18 | namespace Google\Cloud\Samples\BigQuery; |
19 | 19 |
|
20 | | -use Google\Cloud\ClientTrait; |
21 | 20 | use Symfony\Component\Console\Command\Command; |
22 | 21 | use Symfony\Component\Console\Input\InputInterface; |
23 | 22 | use Symfony\Component\Console\Input\InputArgument; |
24 | 23 | use Symfony\Component\Console\Input\InputOption; |
25 | 24 | use Symfony\Component\Console\Output\OutputInterface; |
26 | | -use Symfony\Component\Console\Question\ConfirmationQuestion; |
27 | 25 | use Symfony\Component\Console\Question\Question; |
28 | 26 | use Google\Cloud\ServiceBuilder; |
29 | 27 | use InvalidArgumentException; |
|
36 | 34 | */ |
37 | 35 | class ImportCommand extends Command |
38 | 36 | { |
39 | | - use ClientTrait; |
| 37 | + use ProjectIdTrait; |
40 | 38 |
|
41 | 39 | protected function configure() |
42 | 40 | { |
@@ -89,18 +87,10 @@ protected function execute(InputInterface $input, OutputInterface $output) |
89 | 87 | { |
90 | 88 | $question = $this->getHelper('question'); |
91 | 89 | if (!$projectId = $input->getOption('project')) { |
92 | | - if ($projectId = $this->detectProjectId()) { |
93 | | - if ($input->isInteractive()) { |
94 | | - $message = sprintf('Import data for project %s? [y/n]: ', $projectId); |
95 | | - if (!$question->ask($input, $output, new ConfirmationQuestion($message))) { |
96 | | - return $output->writeln('<error>Task cancelled by user.</error>'); |
97 | | - } |
98 | | - } |
99 | | - } else { |
100 | | - throw new Exception('Could not derive a project ID from gcloud. ' . |
101 | | - 'You must supply a project ID using --project'); |
102 | | - } |
| 90 | + $projectId = $this->getProjectIdFromGcloud(); |
103 | 91 | } |
| 92 | + $message = sprintf('<info>Using project %s</info>', $projectId); |
| 93 | + $output->writeln($message); |
104 | 94 | $fullTableName = $input->getArgument('dataset.table'); |
105 | 95 | if (1 !== substr_count($fullTableName, '.')) { |
106 | 96 | throw new InvalidArgumentException('Table must in the format "dataset.table"'); |
|
0 commit comments