Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
441 views
in Technique[技术] by (71.8m points)

laravel - Call php artisan custom:command with an argument at the end without specifying the ones before

Is there any way that if I have a command of this kind:

protected $signature = 'custom:command {arg1} {arg2} {arg3?} {arg4?} {arg5?}';

To call it without specifying arg4, but with arg5? Something like:

php artisan custom:command arg1_val arg2_val arg3_val arg5_val

Of course, if I do it like above arg5_val will be interpreted like arg4_val and arg5 will be ignored.

I hope my question is clear and it was not answered already. Did not even have a clue how to search for it :))

Thanks in advance!

question from:https://stackoverflow.com/questions/65842661/call-php-artisan-customcommand-with-an-argument-at-the-end-without-specifying-t

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can use optional arguments

// Optional argument...
custom:command {arg5?}

.. but they need to be at the end. Otherwise the command does not know if an argument is left out.

Another way is to use options. Then you can specify these with option_name=option_value


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...