docs icon indicating copy to clipboard operation
docs copied to clipboard

Update the ParseParameters pattern documentation to allow "=" in addition to colon (:) for property value pairs

Open ferventcoder opened this issue 8 years ago • 5 comments

https://github.com/chocolatey/choco/wiki/How-To-Parse-PackageParameters-Argument uses colons for its sample. It should allow equals as well.

@DarwinJS mentions this makes things look inconsistent for how you pass arguments as compared to install arguments, which are typically passed with "=" in between property value pairs.

ferventcoder avatar Jul 08 '16 18:07 ferventcoder

I found something else related to this that is worth making part of this ticket. The captured value has the quotes, and in the case of a path, that makes it invalid path, and is causing warnings. Here is the update expression that doesn't include the quotes, and allows "=" and "-" as the option/value separator.

$match_pattern = "\/(?<option>([a-zA-Z0-9]+))(:|=|-)([`"'])?(?<value>([a-zA-Z0-9- _\\:\.\!\@\#\$\%\^\&\*\(\)+]+))([`"'])?|\/(?<option>([a-zA-Z0-9]+))"

Updated Regex to support numbers in the parameters, and special characters in the value.

The-Running-Dev avatar Dec 01 '16 21:12 The-Running-Dev

I also found that you cannot have numbers in parameter names.

DarwinJS avatar Dec 01 '16 22:12 DarwinJS

Thanks folks!

ferventcoder avatar Feb 01 '17 03:02 ferventcoder

We'll need to update the example, but in 0.10.8, Get-PackageParameters is now part of Chocolatey itself and supports the = - https://github.com/chocolatey/choco/issues/1393

ferventcoder avatar Aug 27 '17 21:08 ferventcoder

We need to check if this still needs to be updated, but this will be completed in the docs repository, so moving it there.

gep13 avatar Jan 20 '22 20:01 gep13