Skip to content

Conversion of input parameter values #31

Closed

Description

@cdhunt

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
        },

Activity

  1. awakecoding commented on Dec 10, 2020

    @awakecoding

    +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

  2. webtroter commented on Dec 23, 2020

    @webtroter

    +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

  3. DonPwrShellHunt commented on Jan 30, 2021

    @DonPwrShellHunt

    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
    
  4. theJasonHelmick commented on Jul 11, 2022

    @theJasonHelmick
    Collaborator

    Chris Hunt (@cdhunt) -- We agree that this would be a good addition. For a workaround today, see #31 (comment)

  5. theJasonHelmick commented on Aug 8, 2023

    @theJasonHelmick
    Collaborator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Issue-EnhancementIssue-Triaged

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions