Skip to content

Commit

Permalink
Fix default values not being passed (#174)
Browse files Browse the repository at this point in the history
  • Loading branch information
jessarcher authored Sep 30, 2024
1 parent 5f99189 commit ea57a22
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
function text(string $label, string $placeholder = '', string $default = '', bool|string $required = false, mixed $validate = null, string $hint = '', ?Closure $transform = null): string
{
return (new TextPrompt(...func_get_args()))->prompt();
return (new TextPrompt(...get_defined_vars()))->prompt();
}
}

Expand All @@ -21,7 +21,7 @@ function text(string $label, string $placeholder = '', string $default = '', boo
*/
function textarea(string $label, string $placeholder = '', string $default = '', bool|string $required = false, mixed $validate = null, string $hint = '', int $rows = 5, ?Closure $transform = null): string
{
return (new TextareaPrompt(...func_get_args()))->prompt();
return (new TextareaPrompt(...get_defined_vars()))->prompt();
}
}

Expand All @@ -31,7 +31,7 @@ function textarea(string $label, string $placeholder = '', string $default = '',
*/
function password(string $label, string $placeholder = '', bool|string $required = false, mixed $validate = null, string $hint = '', ?Closure $transform = null): string
{
return (new PasswordPrompt(...func_get_args()))->prompt();
return (new PasswordPrompt(...get_defined_vars()))->prompt();
}
}

Expand All @@ -44,7 +44,7 @@ function password(string $label, string $placeholder = '', bool|string $required
*/
function select(string $label, array|Collection $options, int|string|null $default = null, int $scroll = 5, mixed $validate = null, string $hint = '', bool|string $required = true, ?Closure $transform = null): int|string
{
return (new SelectPrompt(...func_get_args()))->prompt();
return (new SelectPrompt(...get_defined_vars()))->prompt();
}
}

Expand All @@ -58,7 +58,7 @@ function select(string $label, array|Collection $options, int|string|null $defau
*/
function multiselect(string $label, array|Collection $options, array|Collection $default = [], int $scroll = 5, bool|string $required = false, mixed $validate = null, string $hint = 'Use the space bar to select options.', ?Closure $transform = null): array
{
return (new MultiSelectPrompt(...func_get_args()))->prompt();
return (new MultiSelectPrompt(...get_defined_vars()))->prompt();
}
}

Expand All @@ -68,7 +68,7 @@ function multiselect(string $label, array|Collection $options, array|Collection
*/
function confirm(string $label, bool $default = true, string $yes = 'Yes', string $no = 'No', bool|string $required = false, mixed $validate = null, string $hint = '', ?Closure $transform = null): bool
{
return (new ConfirmPrompt(...func_get_args()))->prompt();
return (new ConfirmPrompt(...get_defined_vars()))->prompt();
}
}

Expand All @@ -78,7 +78,7 @@ function confirm(string $label, bool $default = true, string $yes = 'Yes', strin
*/
function pause(string $message = 'Press enter to continue...'): bool
{
return (new PausePrompt(...func_get_args()))->prompt();
return (new PausePrompt(...get_defined_vars()))->prompt();
}
}

Expand All @@ -100,7 +100,7 @@ function clear(): void
*/
function suggest(string $label, array|Collection|Closure $options, string $placeholder = '', string $default = '', int $scroll = 5, bool|string $required = false, mixed $validate = null, string $hint = '', ?Closure $transform = null): string
{
return (new SuggestPrompt(...func_get_args()))->prompt();
return (new SuggestPrompt(...get_defined_vars()))->prompt();
}
}

Expand All @@ -113,7 +113,7 @@ function suggest(string $label, array|Collection|Closure $options, string $place
*/
function search(string $label, Closure $options, string $placeholder = '', int $scroll = 5, mixed $validate = null, string $hint = '', bool|string $required = true, ?Closure $transform = null): int|string
{
return (new SearchPrompt(...func_get_args()))->prompt();
return (new SearchPrompt(...get_defined_vars()))->prompt();
}
}

Expand All @@ -126,7 +126,7 @@ function search(string $label, Closure $options, string $placeholder = '', int $
*/
function multisearch(string $label, Closure $options, string $placeholder = '', int $scroll = 5, bool|string $required = false, mixed $validate = null, string $hint = 'Use the space bar to select options.', ?Closure $transform = null): array
{
return (new MultiSearchPrompt(...func_get_args()))->prompt();
return (new MultiSearchPrompt(...get_defined_vars()))->prompt();
}
}

Expand Down

0 comments on commit ea57a22

Please sign in to comment.