1515use function Laravel \Prompts \info ;
1616use function Laravel \Prompts \note ;
1717
18- use Symfony \Component \Console \Input \InputInterface ;
19- use Symfony \Component \Console \Output \OutputInterface ;
20- use Illuminate \Console \OutputStyle ;
21-
2218class RunCommand extends BaseCommand
2319{
2420 use GathersInput, ResolvesTemplates;
2521
2622 protected $ signature = 'run
27- {cmd* : Command and arguments to run}
23+ {cmd? * : Command and arguments to run}
2824 {--vault= : Specific vault to use}
2925 {--env= : Environment to use (required)}
3026 {--template= : Template file path, or auto-discover {env}.env if no path given}
@@ -43,26 +39,18 @@ public function __construct(Filesystem $filesystem)
4339 $ this ->processRunner = new ProcessRunner ();
4440 }
4541
46- public function run (InputInterface $ input , OutputInterface $ output ): int
47- {
48- try {
49- return parent ::run ($ input , $ output );
50- } catch (\Symfony \Component \Console \Exception \RuntimeException $ e ) {
51- if (str_contains ($ e ->getMessage (), 'Not enough arguments (missing: "cmd") ' )) {
52- $ this ->output = new OutputStyle ($ input , $ output );
53- error ('No command specified to run ' );
54- note ('Usage: keep run [options] -- <command> [arguments] ' );
55- note ('Example: keep run --vault=ssm --env=production -- npm start ' );
56- note ('Example: keep run --vault=ssm --env=production -- php artisan serve ' );
57- return self ::FAILURE ;
58- }
59- throw $ e ;
60- }
61- }
62-
6342 protected function process (): int
6443 {
6544 $ commandArgs = $ this ->argument ('cmd ' );
45+
46+ if (empty ($ commandArgs )) {
47+ error ('No command specified to run ' );
48+ note ('Usage: keep run [options] -- <command> [arguments] ' );
49+ note ('Example: keep run --vault=ssm --env=production -- npm start ' );
50+ note ('Example: keep run --vault=ssm --env=production -- php artisan serve ' );
51+ return self ::FAILURE ;
52+ }
53+
6654 $ command = $ commandArgs [0 ];
6755 if (!$ this ->processRunner ->commandExists ($ command ) && !file_exists ($ command )) {
6856 error ("Command not found: {$ command }" );
0 commit comments