Skip to content

Better handle commands ran in PowerShell#9878

Draft
aalej wants to merge 5 commits intomainfrom
aalej_fix-7506
Draft

Better handle commands ran in PowerShell#9878
aalej wants to merge 5 commits intomainfrom
aalej_fix-7506

Conversation

@aalej
Copy link
Contributor

@aalej aalej commented Feb 5, 2026

Description

Fixes #7506

Scenarios Tested

TODO

  • Test on an actual windows machine using PowerShell
  • Test on an macOS machine to ensure parsing still works
  • Test on a Linux machine to ensure parsing still works

Sample Commands

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @aalej, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical issue where the CLI failed to correctly parse command arguments when executed in PowerShell environments. By introducing a new utility function, splitArgumentBySeparator, and integrating it across all relevant modules, the change ensures that arguments are consistently and accurately interpreted, regardless of whether they are separated by commas, spaces, or a combination of both. This significantly improves the reliability and user experience for PowerShell users interacting with the CLI.

Highlights

  • New Utility Function for Argument Parsing: Introduced splitArgumentBySeparator in src/utils.ts to robustly parse command-line arguments, specifically addressing issues where PowerShell might incorrectly handle comma-separated values by replacing them with spaces.
  • Widespread Adoption of New Utility: Replaced direct split(",") calls with the new splitArgumentBySeparator utility across numerous files (e.g., src/checkValidTargetFilters.ts, src/commands/functions-config-clone.ts, src/deploy/apphosting/prepare.ts, etc.) to ensure consistent and correct argument parsing throughout the CLI.
  • Comprehensive Testing for Utility: Added new unit tests for splitArgumentBySeparator in src/utils.spec.ts to validate its behavior with various input formats, including spaces, commas, and mixed separators.
  • Increased Test Timeout: The Mocha test timeout in .mocharc.yml was increased from 1000ms to 10000ms, likely to accommodate potential longer execution times or to prevent flaky test failures.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • .mocharc.yml
    • Increased Mocha test timeout from 1000ms to 10000ms.
  • CHANGELOG.md
  • src/checkValidTargetFilters.ts
    • Imported splitArgumentBySeparator from utils.
    • Replaced options.only.split(",") with splitArgumentBySeparator(options.only).
  • src/commands/functions-config-clone.ts
    • Replaced options.only.split(",") and options.except.split(",") with utils.splitArgumentBySeparator().
  • src/commands/serve.ts
    • Replaced only.split(",") with utils.splitArgumentBySeparator(only).
  • src/database/rulesConfig.ts
    • Replaced options.only.split(",") with utils.splitArgumentBySeparator(options.only).
  • src/deploy/apphosting/prepare.ts
    • Imported splitArgumentBySeparator from utils.
    • Replaced options.only.split(",") with splitArgumentBySeparator(options.only).
  • src/deploy/firestore/prepare.ts
    • Replaced options.only.split(",") with utils.splitArgumentBySeparator(options.only).
  • src/deploy/functions/functionsDeployHelper.ts
    • Imported splitArgumentBySeparator from utils.
    • Replaced options.only.split(",") with splitArgumentBySeparator(options.only).
  • src/deploy/lifecycleHooks.ts
    • Replaced options.only.split(",") with utils.splitArgumentBySeparator(options.only).
  • src/deploy/storage/prepare.ts
    • Imported splitArgumentBySeparator from utils.
    • Replaced options.only.split(",") with splitArgumentBySeparator(options.only).
  • src/filterTargets.ts
    • Imported splitArgumentBySeparator from utils.
    • Replaced options.only.split(",") and options.except.split(",") with splitArgumentBySeparator().
  • src/firestore/fsConfig.ts
    • Imported splitArgumentBySeparator from utils.
    • Replaced options.only.split(",") with splitArgumentBySeparator(options.only).
  • src/functions/ensureTargeted.ts
    • Imported splitArgumentBySeparator from utils.
    • Replaced only.split(",") with splitArgumentBySeparator(only).
  • src/utils.spec.ts
    • Added new test suite for splitArgumentBySeparator covering various splitting scenarios.
  • src/utils.ts
    • Added a new exported function splitArgumentBySeparator to handle splitting arguments by spaces and commas.
Activity
  • The pull request was created by aalej to address issue Handle PowerShell comma behavior for parsing command arguments #7506, focusing on improving command argument parsing in PowerShell.
  • Changes were implemented to introduce a new utility function, splitArgumentBySeparator, and integrate it across various modules to ensure robust argument handling.
  • Comprehensive unit tests were added for the new utility to validate its correctness under different conditions.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@aalej aalej marked this pull request as draft February 5, 2026 09:46
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new utility function, splitArgumentBySeparator, to robustly parse command-line arguments that may be separated by commas or spaces, which is particularly useful for improving compatibility with PowerShell. This new function is consistently applied throughout the codebase, replacing direct calls to String.prototype.split(','). Additionally, the global test timeout in .mocharc.yml has been increased.

My feedback includes a suggestion to simplify the new utility function for better conciseness and performance, and a query regarding the significant increase in the test timeout, as it could potentially mask underlying performance issues.

* This is used to hanlde cases where PowerShell replaces commas with spaces.
*/
export function splitArgumentBySeparator(argument: string): string[] {
return argument.split(/[ ,]+/).filter((s) => s.length > 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

While the current implementation is correct, it can be made more concise and potentially more performant by using String.prototype.match() with a regular expression to find all non-separator substrings. This avoids creating intermediate arrays with empty strings that then need to be filtered out.

Suggested change
return argument.split(/[ ,]+/).filter((s) => s.length > 0);
return argument.match(/[^ ,]+/g) || [];

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.

Handle PowerShell comma behavior for parsing command arguments

1 participant