初始化本地仓库
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
---
|
||||
name: backend-command
|
||||
description: 命令行命令规范(Webman Command),支持 make/config/install/metadata/plugin
|
||||
globs:
|
||||
- "app/command/**/*.php"
|
||||
---
|
||||
|
||||
## 文件位置
|
||||
|
||||
```
|
||||
app/command/{Name}Command.php
|
||||
```
|
||||
|
||||
## 代码模板
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
namespace app\command;
|
||||
|
||||
use app\command\BaseCommand;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
#[AsCommand(
|
||||
name: '{name}',
|
||||
description: '{description}',
|
||||
aliases: ['{name}'],
|
||||
hidden: false
|
||||
)]
|
||||
class {Name}Command extends BaseCommand
|
||||
{
|
||||
public function __invoke(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$output->writeln('Done');
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 检查清单
|
||||
|
||||
- [ ] 命令名称是否 kebab-case
|
||||
- [ ] 是否使用 `#[AsCommand]` 注册命令
|
||||
- [ ] 是否有描述信息
|
||||
- [ ] 是否返回正确的 exit code
|
||||
|
||||
## 项目真实约定
|
||||
|
||||
- 当前项目命令通过 `Symfony\Component\Console\Attribute\AsCommand` 自动注册
|
||||
- 当前项目命令通常继承 `app\command\BaseCommand`
|
||||
- 现有命令普遍使用 `public function __invoke(InputInterface $input, OutputInterface $output): int` 作为执行入口
|
||||
Reference in New Issue
Block a user