Skip to content

Conversation

nfedyk
Copy link
Collaborator

@nfedyk nfedyk commented Sep 19, 2025

This PR adds support for explicitly passing empty string values to PowerShell command arguments when configured to allow them. Previously, empty string arguments were filtered out and not included in generated commands. This enhancement provides more flexibility for PowerShell cmdlets that distinguish between omitted parameters and explicitly empty parameters.

The need has originated from the ability to remove the value set for certain properties this is the way to do it via Powershell.

Test coverage has been added to cover the addition.

Change is a nonbreaking change ensuring existing implementation will not break upon upgrade.

Example:

psCommandService.execute("setContent", {
        Path: "./test.txt",
        Value: "",
        Filter: "*.txt"
})

Currently generating:
Set-Content -Path './test.txt' -Filter '*.txt'

Desired output:
Set-Content -Path './test.txt' -Value '' -Filter '*.txt'

This is archived by marking argument Filter as empty in the commend definition.

  getContent: {
    command: "Get-Content {{{arguments}}}",
    arguments: {
      'Path': {},
      'Filter': {
        empty: true,
      },
    },
    return: {
      type: "text",
    },
  },

@nfedyk nfedyk requested a review from Copilot September 19, 2025 15:58
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for explicitly passing empty string values to PowerShell command arguments when configured to allow them. Previously, empty string arguments were filtered out and not included in generated commands.

  • Added empty property configuration to allow empty string values for specific command arguments
  • Modified argument processing logic to include empty strings when explicitly allowed
  • Added comprehensive test coverage and documentation for the new functionality

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
psCommandService.js Core logic changes to support empty argument values via new isEmpty flag
test/unit.js Added test configuration and comprehensive test case for empty value support
README.md Added documentation and version history for the new empty arguments feature

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

nfedyk and others added 2 commits September 19, 2025 11:59
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@bitsofinfo bitsofinfo merged commit 2b77e6a into bitsofinfo:master Sep 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants