-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathIssueCreateCommand.php
More file actions
70 lines (60 loc) · 1.97 KB
/
IssueCreateCommand.php
File metadata and controls
70 lines (60 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
namespace App\Commands;
use Coding\Issue;
use LaravelZero\Framework\Commands\Command;
class IssueCreateCommand extends Command
{
use WithCoding;
/**
* The signature of the command.
*
* @var string
*/
protected $signature = 'issue:create
{--type= : 类型(使用英文),如 DEFECT(缺陷)、REQUIREMENT(需求)、MISSION(任务)、EPIC(史诗)、SUB_TASK(子任务)}
{--name= : 标题}
{--priority=2 : 优先级,0(低), 1(中), 2(高), 3(紧急)}
{--coding_token= : CODING 令牌}
{--coding_team_domain= : CODING 团队域名,如 xxx.coding.net 即填写 xxx}
{--coding_project_uri= : CODING 项目标识,如 xxx.coding.net/p/yyy 即填写 yyy}
';
/**
* The description of the command.
*
* @var string
*/
protected $description = '创建事项';
/**
* Execute the console command.
*
*/
public function handle(Issue $codingIssue): int
{
$this->setCodingApi();
$codingIssue->setToken($this->codingToken);
$data = [
'ProjectName' => $this->codingProjectUri,
];
$data['Type'] = $this->option('type') ?? $this->choice(
'类型:',
['DEFECT', 'REQUIREMENT', 'MISSION', 'EPIC', 'SUB_TASK'],
0
);
$data['Name'] = $this->option('name') ?? $this->ask('标题:');
$data['Priority'] = $this->option('priority') ?? $this->choice(
'优先级:',
['0', '1', '2', '3'],
0
);
try {
$result = $codingIssue->create($data);
} catch (\Exception $e) {
$this->error('Error: ' . $e->getMessage());
return 1;
}
$this->info('创建成功');
$this->info("https://{$this->codingTeamDomain}.coding.net/p/{$this->codingProjectUri}" .
"/all/issues/${result['Code']}");
return 0;
}
}