Crescendo icon indicating copy to clipboard operation
Crescendo copied to clipboard

Conversion of input parameter values

Open cdhunt opened this issue 4 years ago • 4 comments

The binary I'm working with takes a comma-delimited list of strings. I would like to take in a string[] and simply -join '' at runtime.

Args list should look like this

list
items
--categories
passwords,logins

Currently looks like this.

list
items
--categories
passwords
logins

Definition

        {
            "Name": "Categories",
            "OriginalName": "--categories",
            "ParameterType": "string[]",
            "Description": "Only list items in these categories",
            "Position": 0
        },

cdhunt avatar Dec 10 '20 14:12 cdhunt

+1 on this, parameter transformation is also very commonly needed for all types of array parameters. Sometimes you need to pass each value as with the same repeated parameter, sometimes it's encoded as a single value joined by a character like ',', etc.

One example is the Docker CLI that takes environment variables as a series of "-e NAME="VAL"" parameters. Here's how I do it: https://github.com/Devolutions/WaykBastion-ps/blob/master/WaykBastion/Private/DockerHelper.ps1#L367

awakecoding avatar Dec 10 '20 20:12 awakecoding

+1 too. I would like to transform a PSCredential so I can map it to --username and --password. Cause we all know that is not secure. Related to #34

webtroter avatar Dec 23 '20 22:12 webtroter

Glob Pattern strings need to be single quoted before passing to native cmd

I am working on GitHub CLI and need to have an input parameter single quoted since it is a glob pattern. Without the single quotes, at runtime it executes the glob matching before the native command gets control. As an experiment, I tried specifying the string like "'*pkg'" to the PowerShell parameter - but the native cmd could not find a match. I was able to test the native cmd successfully using --pattern '*pkg'

# download only Debian packages for the latest release
$ gh release download --pattern '*.deb'
Copy-GHReleaseAsset -Tag 'v7.1.1' -Pattern "'*pkg'"  -Repo 'PowerShell/PowerShell' -Verbose
VERBOSE: gh
VERBOSE: release
VERBOSE: download
VERBOSE: v7.1.1
VERBOSE: --pattern
VERBOSE: '*pkg'
VERBOSE: --repo
VERBOSE: PowerShell/PowerShell
VERBOSE: Performing the operation "Copy-GHReleaseAsset" on target "gh".
no assets match the file pattern

DonPwrShellHunt avatar Jan 30 '21 16:01 DonPwrShellHunt

@cdhunt -- We agree that this would be a good addition. For a workaround today, see https://github.com/PowerShell/Crescendo/issues/31#issuecomment-770240370

theJasonHelmick avatar Jul 11 '22 20:07 theJasonHelmick

Thank you! Fixed/closed - in release: https://www.powershellgallery.com/packages/Microsoft.PowerShell.Crescendo/1.1.0-RC1

theJasonHelmick avatar Aug 08 '23 16:08 theJasonHelmick