Skip to content
This repository was archived by the owner on Mar 20, 2025. It is now read-only.

Commit 3f948f8

Browse files
committed
Convert remaining commands + remove old tests
1 parent a11954e commit 3f948f8

File tree

4 files changed

+49
-132
lines changed

4 files changed

+49
-132
lines changed

shift-cli

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
#!/usr/bin/env php
22
<?php
3-
// application.php
43

5-
require __DIR__.'/vendor/autoload.php';
4+
require __DIR__ . '/vendor/autoload.php';
65

7-
use Illuminate\Support\Env;
8-
use Shift\Cli\Support\TaskManifest;
9-
use Symfony\Component\Console\Application;
106
use Shift\Cli\Commands\DiscoverCommand;
11-
//use Shift\Cli\Commands\HelpCommand;
12-
use Shift\Cli\Commands\RunCommand;
137
use Shift\Cli\Commands\PublishCommand;
8+
use Shift\Cli\Commands\RunCommand;
9+
use Shift\Cli\Support\TaskManifest;
10+
use Symfony\Component\Console\Application;
1411

12+
$taskManifest = new TaskManifest(getenv('COMPOSER_VENDOR_DIR') ?: getcwd() . '/vendor');
1513

16-
$command = new RunCommand(new TaskManifest(Env::get('COMPOSER_VENDOR_DIR') ?: getcwd() . '/vendor'));
1714
$application = new Application();
18-
$application->add($command);
19-
$application->setDefaultCommand($command->getName());
15+
$application->add(new DiscoverCommand($taskManifest));
16+
$application->add(new PublishCommand());
17+
$application->add(new RunCommand($taskManifest));
18+
$application->setDefaultCommand('run');
2019
$application->run();

src/Commands/DiscoverCommand.php

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,38 @@
22

33
namespace Shift\Cli\Commands;
44

5-
use Illuminate\Console\Command;
65
use Shift\Cli\Support\TaskManifest;
6+
use Symfony\Component\Console\Attribute\AsCommand;
7+
use Symfony\Component\Console\Command\Command;
8+
use Symfony\Component\Console\Input\InputInterface;
9+
use Symfony\Component\Console\Output\OutputInterface;
710

11+
#[AsCommand(
12+
name: 'discover',
13+
description: 'Load any additional automated tasks within the project',
14+
)]
815
class DiscoverCommand extends Command
916
{
10-
protected $signature = 'discover';
17+
private TaskManifest $taskManifest;
1118

12-
protected $description = 'Load any additional automated tasks within the project';
19+
public function __construct(TaskManifest $taskManifest)
20+
{
21+
parent::__construct();
22+
23+
$this->taskManifest = $taskManifest;
24+
}
1325

14-
public function handle(TaskManifest $manifest)
26+
protected function execute(InputInterface $input, OutputInterface $output): int
1527
{
16-
$this->components->info('Discovering tasks');
28+
$output->writeln('Discovering tasks');
1729

18-
$manifest->build();
30+
$this->taskManifest->build();
1931

20-
collect($manifest->list())
32+
collect($this->taskManifest->list())
2133
->keys()
22-
->each(fn ($task) => $this->components->task($task))
23-
->whenNotEmpty(fn () => $this->newLine());
34+
->each(fn ($task) => $output->writeln($task))
35+
->whenNotEmpty(fn () => $output->writeln(''));
36+
37+
return 0;
2438
}
2539
}

src/Commands/PublishCommand.php

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,28 @@
22

33
namespace Shift\Cli\Commands;
44

5-
use LaravelZero\Framework\Commands\Command;
65
use Shift\Cli\Sdk\Facades\Configuration;
7-
6+
use Symfony\Component\Console\Attribute\AsCommand;
7+
use Symfony\Component\Console\Command\Command;
8+
use Symfony\Component\Console\Input\InputInterface;
9+
use Symfony\Component\Console\Input\InputOption;
10+
use Symfony\Component\Console\Output\OutputInterface;
11+
12+
#[AsCommand(
13+
name: 'publish',
14+
description: 'Publish a default Shift CLI configuration file',
15+
)]
816
class PublishCommand extends Command
917
{
10-
protected $signature = 'publish {--force : Overwrite any existing files}';
11-
12-
protected $description = 'Publish a default Shift CLI configuration file';
18+
protected function configure(): void
19+
{
20+
$this->addOption('force', mode: InputOption::VALUE_NONE, description: 'Overwrite existing configuration file');
21+
}
1322

14-
public function handle(): int
23+
protected function execute(InputInterface $input, OutputInterface $output): int
1524
{
16-
if (file_exists('shift-cli.json') && ! $this->option('force')) {
17-
$this->line('<comment>A configuration file already exists.</comment> Use the `--force` option to overwrite yours.');
25+
if (file_exists('shift-cli.json') && ! $input->getOption('force')) {
26+
$output->writeln('<comment>A configuration file already exists.</comment> Use the `--force` option to overwrite yours.');
1827

1928
return 1;
2029
}

tests/Feature/Commands/RunCommandTest.php

Lines changed: 0 additions & 105 deletions
This file was deleted.

0 commit comments

Comments
 (0)