Skip to content

Commit 967bdac

Browse files
committed
Uses command name accessor
1 parent f7aa649 commit 967bdac

6 files changed

Lines changed: 37 additions & 37 deletions

File tree

src/Commands/CreateCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7373
if (\file_exists($gitattributesPath) && $this->isDryRun($input) !== true) {
7474
$message = 'A .gitattributes file already exists. Use the update command to modify it.';
7575
if ($isAgenticRun) {
76-
$this->writeAgenticOutput($output, 'create', false, $message);
76+
$this->writeAgenticOutput($output, $this->getName(), false, $message);
7777
} else {
7878
$output->writeln($message);
7979
}
@@ -85,7 +85,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8585
if ($expected === '') {
8686
$message = 'Unable to determine expected .gitattributes content for the given directory.';
8787
if ($isAgenticRun) {
88-
$this->writeAgenticOutput($output, 'create', false, $message);
88+
$this->writeAgenticOutput($output, $this->getName(), false, $message);
8989
} else {
9090
$output->writeln($message);
9191
}
@@ -104,7 +104,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
104104
} catch (\Throwable $e) {
105105
$message = 'Creation of .gitattributes file failed.';
106106
if ($isAgenticRun) {
107-
$this->writeAgenticOutput($output, 'create', false, $message);
107+
$this->writeAgenticOutput($output, $this->getName(), false, $message);
108108
} else {
109109
$output->writeln($message);
110110
}
@@ -114,7 +114,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
114114
$directory = \realpath($directory);
115115
$message = "A .gitattributes file has been created in {$directory}.";
116116
if ($isAgenticRun) {
117-
$this->writeAgenticOutput($output, 'create', true, $message, ['gitattributes_file_path' => $gitattributesPath]);
117+
$this->writeAgenticOutput($output, $this->getName(), true, $message, ['gitattributes_file_path' => $gitattributesPath]);
118118
} else {
119119
$output->writeln($message);
120120
}

src/Commands/InitCommand.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
111111
$warning = "Warning: The provided directory "
112112
. "'{$directory}' does not exist or is not a directory.";
113113
if ($isAgenticRun) {
114-
$this->writeAgenticOutput($output, 'init', false, $warning);
114+
$this->writeAgenticOutput($output, $this->getName(), false, $warning);
115115
} else {
116116
$output->writeln('<error>' . $warning . '</error>');
117117
}
@@ -129,7 +129,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
129129
if (\file_exists($defaultLpvFile) && $overwriteDefaultLpvFile === false) {
130130
$warning = 'Warning: A default .lpv file already exists.';
131131
if ($isAgenticRun) {
132-
$this->writeAgenticOutput($output, 'init', false, $warning);
132+
$this->writeAgenticOutput($output, $this->getName(), false, $warning);
133133
} else {
134134
$output->writeln('<error>' . $warning . '</error>');
135135
}
@@ -144,7 +144,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
144144
} else {
145145
$warning = 'Warning: Chosen preset ' . $chosenPreset . ' is not available. Maybe contribute it?.';
146146
if ($isAgenticRun) {
147-
$this->writeAgenticOutput($output, 'init', false, $warning);
147+
$this->writeAgenticOutput($output, $this->getName(), false, $warning);
148148
} else {
149149
$output->writeln('<error>' . $warning . '</error>');
150150
}
@@ -175,7 +175,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
175175
if ($bytesWritten === false) {
176176
$warning = 'Warning: The creation of the default .lpv file failed.';
177177
if ($isAgenticRun) {
178-
$this->writeAgenticOutput($output, 'init', false, $warning);
178+
$this->writeAgenticOutput($output, $this->getName(), false, $warning);
179179
} else {
180180
$output->writeln('<error>' . $warning . '</error>');
181181
}
@@ -186,7 +186,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
186186
$message = "Created default '{$defaultLpvFile}' file.";
187187

188188
if ($isAgenticRun) {
189-
$this->writeAgenticOutput($output, 'init', true, $message, ['lpv_file_path' => $defaultLpvFile]);
189+
$this->writeAgenticOutput($output, $this->getName(), true, $message, ['lpv_file_path' => $defaultLpvFile]);
190190
} else {
191191
$output->writeln("<info>{$message}</info>");
192192
}

src/Commands/RefreshCommand.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
108108
$warning = "Warning: The provided directory "
109109
. "'{$directory}' does not exist or is not a directory.";
110110
if ($isAgenticRun) {
111-
$this->writeAgenticOutput($output, 'refresh', false, $warning);
111+
$this->writeAgenticOutput($output, $this->getName(), false, $warning);
112112
} else {
113113
$output->writeln('<error>' . $warning . '</error>');
114114
}
@@ -123,7 +123,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
123123
if (!\file_exists($defaultLpvFile) && $this->isDryRun($input) !== true) {
124124
$warning = 'Warning: No default .lpv file exists to refresh.';
125125
if ($isAgenticRun) {
126-
$this->writeAgenticOutput($output, 'refresh', false, $warning);
126+
$this->writeAgenticOutput($output, $this->getName(), false, $warning);
127127
} else {
128128
$output->writeln('<error>' . $warning . '</error>');
129129
}
@@ -133,7 +133,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
133133
if ($chosenPreset === '' || !\in_array(\strtolower($chosenPreset), \array_map('strtolower', $this->finder->getAvailablePresets()), true)) {
134134
$warning = 'Warning: Chosen preset ' . $chosenPreset . ' is not available. Maybe contribute it?.';
135135
if ($isAgenticRun) {
136-
$this->writeAgenticOutput($output, 'refresh', false, $warning);
136+
$this->writeAgenticOutput($output, $this->getName(), false, $warning);
137137
} else {
138138
$output->writeln('<error>' . $warning . '</error>');
139139
}
@@ -178,7 +178,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
178178
if ($bytesWritten === false) {
179179
$warning = 'Warning: The refresh of the default .lpv file failed.';
180180
if ($isAgenticRun) {
181-
$this->writeAgenticOutput($output, 'refresh', false, $warning);
181+
$this->writeAgenticOutput($output, $this->getName(), false, $warning);
182182
} else {
183183
$output->writeln('<error>' . $warning . '</error>');
184184
}
@@ -187,7 +187,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
187187

188188
$message = "Refreshed default '{$defaultLpvFile}' file.";
189189
if ($isAgenticRun) {
190-
$this->writeAgenticOutput($output, 'refresh', true, $message, ['lpv_file_path' => $defaultLpvFile]);
190+
$this->writeAgenticOutput($output, $this->getName(), true, $message, ['lpv_file_path' => $defaultLpvFile]);
191191
} else {
192192
$output->writeln($message);
193193
}

src/Commands/TreeCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7070
$warning = "Warning: The provided directory "
7171
. "'{$this->directoryToOperateOn}' does not exist or is not a directory.";
7272
if ($isAgenticRun) {
73-
$this->writeAgenticOutput($output, 'tree', false, $warning);
73+
$this->writeAgenticOutput($output, $this->getName(), false, $warning);
7474
} else {
7575
$output->writeln('<error>' . $warning . '</error>');
7676
}
@@ -88,7 +88,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8888

8989
if ($isAgenticRun) {
9090
$treeLines = \array_values(\array_filter(\explode(PHP_EOL, \rtrim($treeOutput)), static fn (string $l): bool => \trim($l) !== ''));
91-
$this->writeAgenticOutput($output, 'tree', true, "Package: {$packageName}", ['package' => $packageName, 'tree' => $treeLines]);
91+
$this->writeAgenticOutput($output, $this->getName(), true, "Package: {$packageName}", ['package' => $packageName, 'tree' => $treeLines]);
9292
} else {
9393
$output->writeln('Package: <info>' . $packageName . '</info>');
9494
$output->write($treeOutput);
@@ -105,15 +105,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int
105105

106106
if ($isAgenticRun) {
107107
$treeLines = \array_values(\array_filter(\explode(PHP_EOL, \rtrim($treeToDisplay)), static fn (string $l): bool => \trim($l) !== ''));
108-
$this->writeAgenticOutput($output, 'tree', true, "Package: {$packageName}", ['package' => $packageName, 'tree' => $treeLines]);
108+
$this->writeAgenticOutput($output, $this->getName(), true, "Package: {$packageName}", ['package' => $packageName, 'tree' => $treeLines]);
109109
} else {
110110
$output->writeln('Package: <info>' . $packageName . '</info>');
111111
$output->write($treeToDisplay);
112112
}
113113
} catch (GitHeadNotAvailable $e) {
114114
$message = 'Directory ' . $this->directoryToOperateOn . ' has no Git Head.';
115115
if ($isAgenticRun) {
116-
$this->writeAgenticOutput($output, 'tree', false, $message);
116+
$this->writeAgenticOutput($output, $this->getName(), false, $message);
117117
} else {
118118
$output->writeln('Directory <info>' . $this->directoryToOperateOn . '</info> has no Git Head.');
119119
}

src/Commands/UpdateCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7979

8080
if (!\file_exists($gitattributesPath) && $this->isDryRun($input) !== true) {
8181
if ($isAgenticRun) {
82-
$this->writeAgenticOutput($output, 'update', false, 'No .gitattributes file found. Use the create command to create one first.');
82+
$this->writeAgenticOutput($output, $this->getName(), false, 'No .gitattributes file found. Use the create command to create one first.');
8383
} else {
8484
$output->writeln('No .gitattributes file found. Use the <info>create</info> command to create one first.');
8585
}
@@ -91,7 +91,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9191
if ($expected === '') {
9292
$message = 'Unable to determine expected .gitattributes content for the given directory.';
9393
if ($isAgenticRun) {
94-
$this->writeAgenticOutput($output, 'update', false, $message);
94+
$this->writeAgenticOutput($output, $this->getName(), false, $message);
9595
} else {
9696
$output->writeln($message);
9797
}
@@ -110,7 +110,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
110110
} catch (\Throwable $e) {
111111
$message = 'Update of .gitattributes file failed.';
112112
if ($isAgenticRun) {
113-
$this->writeAgenticOutput($output, 'update', false, $message);
113+
$this->writeAgenticOutput($output, $this->getName(), false, $message);
114114
} else {
115115
$output->writeln($message);
116116
}
@@ -120,7 +120,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
120120
$directory = \realpath($directory);
121121
$message = "The .gitattributes file in {$directory} has been updated.";
122122
if ($isAgenticRun) {
123-
$this->writeAgenticOutput($output, 'update', true, $message, ['gitattributes_file_path' => $gitattributesPath]);
123+
$this->writeAgenticOutput($output, $this->getName(), true, $message, ['gitattributes_file_path' => $gitattributesPath]);
124124
} else {
125125
$output->writeln($message);
126126
}

0 commit comments

Comments
 (0)