我经营工匠:
$triggerAlias = $env:RELEASE_TRIGGERINGARTIFACT_ALIAS
$branchNameVariable = "RELEASE_ARTIFACTS_$($triggerAlias)_SOURCEBRANCHNAME"
#Get the value of the environment variable Release.Artifacts.{alias}.SourceBranchName
$branchName = (Get-item env:$branchNameVariable).Value
[更新]或像@Remul建议的那样运行它:
php artisan down --message "Going down for maintenance" --retry=60
然后两者都给我错误:
php artisan down --message="Going down for maintenance" --retry=60
如果运行命令中没有这样的空格:
[Symfony\Component\Console\Exception\RuntimeException]
Too many arguments, expected arguments "command".
没有错误发生
答案 0 :(得分:3)
我正在使用php 7.0.14
我想通了:
问题实际上是php从命令行获取参数的方式 在vendor / symfony / console / Input / ArgvInput.php中,我可以理解php会遇到如下问题:
0 => "artisan"
1 => "down"
2 => "--message=Going"
3 => "down"
4 => "for"
5 => "maintenance"
6 => "--retry=60"
因此,甚至要确保我使用以下内容制作了自己的脚本:
<?php
var_dump($argv);
我运行它:
php -v;php test_argv.php "parm with space" other_parameter
输出为:
PHP 7.0.14 (cli) (built: Jan 30 2017 15:45:33) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
array(5) {
[0]=>
string(13) "test_argv.php"
[1]=>
string(4) "parm"
[2]=>
string(4) "with"
[3]=>
string(5) "space"
[4]=>
string(15) "other_parameter"
}
我在其他装有不同版本PHP的计算机上运行它,并查看结果:
PHP 7.1.5 (cli) (built: Sep 19 2017 10:48:01) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
with Xdebug v2.5.4, Copyright (c) 2002-2017, by Derick Rethans
array(3) {
[0] =>
string(13) "test_argv.php"
[1] =>
string(15) "parm with space"
[2] =>
string(15) "other_parameter"
}
像在php 7.0和7.1中argv的解析是完全不同的,人们会忽略双引号作为字符串定界符,而后面的则不会这样做
答案 1 :(得分:1)
我遇到了同样的问题,只需要使用反斜杠转义消息即可:
class bank_account:
def __init__(self, account_number, name, balance):
self.account_number = account_number
self.name = name
self.balance = balance
def withdraw(self, amount):
if amount > self.balance:
print("Insufficient Funds")
else:
self.balance = self.balance - amount
def deposit(self, amount):
if amount <= 0:
print("Invalid Amount")
else:
self.balance = self.balance + amount
def check_balance(self):
print(self.balance)
account_number = int(input("Enter your account number: ")) # <=== Add this
name = input("Enter your Name: ") # <=== Add this
balance = int(input("Enter your balance: ")) # <=== Add this
account_holder = bank_account(account_number, name, balance) # <=== Add this
transaction = input("Please enter what transaction you would like to do: (Withdraw, Deposit) ")
amount = int(input("Enter the amount you would like to deposit or withdraw: "))
if transaction == 'withdraw' or transaction == 'Withdraw':
account_holder.withdraw(amount)
print(account_holder.check_balance())
elif transaction == 'deposit' or transaction == 'Deposit':
account_holder.deposit(amount)
答案 2 :(得分:-1)
此消息在由php artisan down命令生成的名为storage / framework / down的JSON格式文件中可用。
您可以打开该文件并进行修改。
祝你好运
答案 3 :(得分:-1)
这是一个不相关的问题,但这是Google在我犯此错误时向我发送邮件的地方...太棒了。
获得此信息的另一个常见原因:
Too many arguments, expected arguments "command".
是当工匠脚本需要一个选项时,您正在提供一个参数。所以你需要改变
./artisan yourcommand:yoursubcommand some_kind_of_input
到
./artisan yourcommand:yoursubcommand --an_option=some_kind_of_input
该错误通常意味着工匠不希望此命令有任何其他形式的参数...