【发布时间】:2014-12-16 14:01:50
【问题描述】:
我正在尝试尽可能严格地遵守 Microsoft 的 Powershell 开发指南和最佳实践,但我在导入自定义模块时收到警告:
WARNING: The names of some imported commands from the module 'F5Helper' include unapproved verbs that might make them less discoverable.
To find the commands with unapproved verbs, run the Import-Module command again with the Verbose parameter. For a list of approved verbs, type Get-Verb.
VERBOSE: The 'Create-iRule' command in the F5Helper' module was imported, but because its name does not include an approved verb, it might be difficult to find.
The suggested alternative verbs are "New".
VERBOSE: Importing function 'Create-iRule'.
我在其他任何地方都找不到信息,但也许这里有人可以告诉我为什么应该使用 New 一词而不是 Create 一词?
在我的例子中,“Create-iRule”函数就是这样做的,它创建了一个 iRule。
我知道有人一定会发布一个回答说:“但是你正在创建一个'New-iRule'所以它应该是函数的名称!” 对于这些人,我会提醒您,New 不是动词,而 Create 是。
那么为什么 New 在已批准的动词列表中并且 Create 会输出警告?
【问题讨论】:
-
+1 指出“新”实际上不是动词!让我想起另一个行业的一句名言:'chicken' 不应该用作形容词。(如炸鸡排)。 :-)
-
这就是为什么我总是不小心写了 Create-Item 然后不得不把它改成 New-Item。因为“新”不是动词。这让我很恼火。我们可以被称为书呆子,但脚本编写者必须要构建好的脚本。没有什么比电脑更迂腐的了。
-
在英语中,任何名词都可以做动词。诚然,“现在”也不是名词。但也许任何词都可以动词化。
-
'Verbed' 是我最喜欢的动词化名词。我喜欢动词名词。
-
微软添加了关于使用 New 作为动词的评论(英文网站),并扩展了如何选择动词。我更新了 OP 问题中的链接以转到原始页面的更新位置。
标签: powershell