-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathIterationCreateCommand.php
64 lines (54 loc) · 1.93 KB
/
IterationCreateCommand.php
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
<?php
namespace App\Commands;
use App\Coding\Iteration;
use Carbon\Carbon;
use LaravelZero\Framework\Commands\Command;
class IterationCreateCommand extends Command
{
use WithCoding;
/**
* The signature of the command.
*
* @var string
*/
protected $signature = 'iteration:create
{--start_at= : 开始时间,格式:2021-10-20}
{--end_at= : 结束时间,格式:2021-10-30}
{--name= : 标题}
{--goal= : 目标}
{--assignee= : 处理人 ID}
{--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(Iteration $iteration): int
{
$this->setCodingApi();
$data = [];
$startAt = Carbon::parse($this->option('start_at') ?? $this->ask('开始时间:', Carbon::today()->toDateString()));
$data['StartAt'] = $startAt->toDateString();
$endAt = Carbon::parse($this->option('end_at') ?? $this->ask(
'结束时间:',
Carbon::today()->addDays(14)->toDateString()
));
$data['EndAt'] = $endAt->toDateString();
$data['Name'] = $this->option('name') ?? $this->ask('标题:', Iteration::generateName($startAt, $endAt));
$data['Goal'] = $this->option('goal');
$data['Assignee'] = $this->option('assignee');
$result = $iteration->create($this->codingToken, $this->codingProjectUri, $data);
$this->info('创建成功');
$this->info("https://{$this->codingTeamDomain}.coding.net/p/{$this->codingProjectUri}" .
"/iterations/${result['Code']}/issues");
return 0;
}
}