Skip to content

Commit 0c24032

Browse files
authored
Merge pull request #372 from jolicode/autocomplete-de-malade
Autocomplete --service option
2 parents 1ba0f68 + 1541135 commit 0c24032

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 = [],
@@ -579,3 +582,11 @@ function get_services(): array
579582
true,
580583
)['services'];
581584
}
585+
586+
/**
587+
* @return string[]
588+
*/
589+
function get_service_names(): array
590+
{
591+
return array_keys(get_services());
592+
}

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)