Skip to content

Commit 1541135

Browse files
committed
Autocomplete --service option
1 parent 567592d commit 1541135

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

.castor/docker.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ function open_project(): void
6868

6969
#[AsTask(description: 'Builds the infrastructure', aliases: ['build'])]
7070
function build(
71+
#[AsOption(description: 'The service to build (default: all services)', autocomplete: 'docker\get_service_names')]
7172
?string $service = null,
7273
?string $profile = null,
7374
): void {
@@ -103,6 +104,7 @@ function build(
103104
*/
104105
#[AsTask(description: 'Builds and starts the infrastructure', aliases: ['up'])]
105106
function up(
107+
#[AsOption(description: 'The service to start (default: all services)', autocomplete: 'docker\get_service_names')]
106108
?string $service = null,
107109
#[AsOption(mode: InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED)]
108110
array $profiles = [],
@@ -133,6 +135,7 @@ function up(
133135
*/
134136
#[AsTask(description: 'Stops the infrastructure', aliases: ['stop'])]
135137
function stop(
138+
#[AsOption(description: 'The service to stop (default: all services)', autocomplete: 'docker\get_service_names')]
136139
?string $service = null,
137140
#[AsOption(mode: InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED)]
138141
array $profiles = [],
@@ -577,3 +580,11 @@ function get_services(): array
577580
true,
578581
)['services'];
579582
}
583+
584+
/**
585+
* @return string[]
586+
*/
587+
function get_service_names(): array
588+
{
589+
return array_keys(get_services());
590+
}

castor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// use function docker\workers_start;
1616
// use function docker\workers_stop;
1717

18-
guard_min_version('0.18.0');
18+
guard_min_version('0.26.0');
1919

2020
import(__DIR__ . '/.castor');
2121

0 commit comments

Comments
 (0)