践行清洁代码

践行清洁代码

我有一个脚本,如果一直放在同一行,编辑起来会很麻烦。但是在我想要换行的地方,运行时出现错误,

-ApplicationParameter:术语“-ApplicationParameter”未被识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,或者如果包含路径,请验证路径是否正确,然后重试。

我只是希望它看起来干净,因为我会在每次部署时对其进行编辑。

# Installs the application
New-ServiceFabricApplication -ApplicationName $ApplicationName -ApplicationTypeName $ApplicationType -ApplicationTypeVersion $ApplicationVersion |
-ApplicationParameter @{
 Logic_ASPNETCORE_ENVIRONMENT = "LOCAL";
 Logic_InstanceCount = "1";
 Logic_ServiceUser = "switchcommerce\localdevgmsa";
 Data_ASPNETCORE_ENVIRONMENT = "LOCAL";
 Data_PartitionCount = "1";
 Data_MinReplicaSetSize = "3";
 Data_TargetReplicaSetSize = "3";
 Data_ServiceUser = "switchcommerce\localdevgmsa";
}

我尝试使用“|”符号和n andr,但没有成功。有没有办法让它看起来像这样,但确保它会运行?或者你只是无法用参数开始一行:-ApplicationParameter

答案1

事实上,我想我明白了。我选择了:

# Installs the application
New-ServiceFabricApplication `
    -ApplicationName $ApplicationName `
    -ApplicationTypeName $ApplicationType `
    -ApplicationTypeVersion $ApplicationVersion `
    -ApplicationParameter @{
        Logic_ASPNETCORE_ENVIRONMENT = "LOCAL";
        Logic_InstanceCount = "1";
        Logic_ServiceUser = "switchcommerce\localdevgmsa";
        Data_ASPNETCORE_ENVIRONMENT = "LOCAL";
        Data_PartitionCount = "1";
        Data_MinReplicaSetSize = "3";
        Data_TargetReplicaSetSize = "3";
        Data_ServiceUser = "switchcommerce\localdevgmsa";
    }

看起来这已经奏效了。现在正在解决实际参数值的一些问题。谢谢!

相关内容