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

Categories

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

php - 参数过多,预??期参数“命令”(Too many arguments, expected arguments “command”)

I'm trying to run a custom command through the terminal, but keep getting the error: Too many arguments, expected arguments "command".

(我正在尝试通过终端运行自定义命令,但始终出现错误:参数过多,预??期参数“ command”过多。)

When searching for similar issues all i've been able to find was people using the scheduler, and nothing about calling the command from terminal.

(当搜索类似的问题时,我只能找到使用调度程序的人,而与从终端调用命令无关。)

The signature for the command i'm trying to run is:

(我尝试运行的命令的签名是:)

class MigrateSiteMysiteCommand extends Command
{
protected $signature = 'migrate:site:mysite.dk {--from=} {--to=}';
...

And then i use php artisan help migrate:site:mysite.dk i get this:

(然后,我使用php artisan帮助迁移:site:mysite.dk,我得到了:)

Usage:
migrate:site:mysite.dk [options]

Options:
   --from[=FROM]
   --to[=TO]
-h,--help            Display this help message
-q,--quiet           Do not output any message
-V,--version         Display this application version
   --ansi            Force ANSI output
   --no-ansi         Disable ANSI output
-n,--no-interaction  Do not ask any interactive question
   --env[=ENV]       The environment the command should run under
-v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose 
output and 3 for debug

I've tried running the command in different ways formatting the arguments, but get the same error either way:

(我尝试以不同的方式设置参数的格式来运行命令,但是无论哪种方式都会遇到相同的错误:)

php artisan migrate:site:mysite.dk --from=2019-02-27 16:22:10 --to=2019-02-28 23:59:59

(php artisan migration:site:mysite.dk --from = 2019-02-27 16:22:10 --to = 2019-02-28 23:59:59)

php artisan migrate:site:mysite.dk --from='2019-02-27 16:22:10' --to='2019-02-28 23:59:59'

(php artisan migration:site:mysite.dk --from ='2019-02-27 16:22:10'--to ='2019-02-28 23:59:59')

php artisan migrate:site:mysite.dk --from '2019-02-27 16:22:10' --to '2019-02-28 23:59:59'

(php artisan migration:site:mysite.dk-从'2019-02-27 16:22:10'-到'2019-02-28 23:59:59')

php artisan migrate:site:mysite.dk --from 2019-02-27 16:22:10 --to 2019-02-28 23:59:59

(php artisan migration:site:mysite.dk-从2019-02-27 16:22:10-到2019-02-28 23:59:59)

Any suggestions to what i'm missing, or messing up in the command ?

(关于我所缺少的任何建议,或在命令中弄乱了什么?)

I've been able to run other commands, which didn't need any arguments passed.

(我已经能够运行其他命令,这些命令不需要传递任何参数。)

  ask by KristianMedK translate from so

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

1 Reply

0 votes
by (71.8m points)

参数必须用“而不是”包装,因此工作命令如下所示:

php artisan migrate:site:mysite.dk --from="2019-02-27 16:22:10" --to="2019-02-28 23:59:59"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...