0
我目前正在爲Powershell v2.0中的Subversion命令行編寫一個包裝器。我希望能夠遵循命令行儘可能接近的方式。所以,舉例來說,我希望「SVN信息」命令:阻止函數使用位置參數,除了ValueFromRemainingArguments參數
info: Display information about a local or remote item.
usage: info [TARGET[@REV]...]
Print information about each TARGET (default: '.').
TARGET may be either a working-copy path or URL. If specified, REV
determines in which revision the target is first looked up.
Valid options:
-r [--revision] ARG : ARG (some commands also take ARG1:ARG2 range)
A revision argument can be one of:
NUMBER revision number
'{' DATE '}' revision at start of the date
'HEAD' latest in repository
'BASE' base rev of item's working copy
'COMMITTED' last commit at or before BASE
'PREV' revision just before COMMITTED
-R [--recursive] : descend recursively, same as --depth=infinity
--depth ARG : limit operation by depth ARG ('empty', 'files',
'immediates', or 'infinity')
--targets ARG : pass contents of file ARG as additional args
--incremental : give output suitable for concatenation
--xml : output in XML
--changelist [--cl] ARG : operate only on members of changelist ARG
Global options:
--username ARG : specify a username ARG
--password ARG : specify a password ARG
--no-auth-cache : do not cache authentication tokens
--non-interactive : do no interactive prompting
--trust-server-cert : accept SSL server certificates from unknown
certificate authorities without prompting (but only
with '--non-interactive')
--config-dir ARG : read user configuration files from directory ARG
--config-option ARG : set user configuration option in the format:
FILE:SECTION:OPTION=[VALUE]
For example:
servers:global:http-library=serf
...映射到功能如下:
function Svn-Info {
param(
$revision,
$depth,
$targets,
$incremental,
$changelist,
$username,
$password,
$no_auth_cache,
$non_interactive,
$trust_server_cert,
$config_dir,
$config_option,
[Parameter(Mandatory=$false,ValueFromRemainingArguments=$true)]
[String[]]
$targetsAtRev
)
我想這樣稱呼它:
Svn-Info "D:\svn\"@25345 "D:\svn\common\"@35922 -username MyUserName -password MyPassword
不幸的是,它試圖將前兩個參數綁定到$ revision和$ depth(基本上,前兩個參數沒有已經被綁定)。所以基本上,我可以以某種方式停止參數綁定位置的任意數量的參數?
好極了!我認爲這可以做到。謝謝。 –