Skip to content

dataconnect: emulator.sh: add fancy command-line argument parsing to improve devx #7172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 22, 2025

Conversation

dconeybe
Copy link
Contributor

@dconeybe dconeybe commented Jul 22, 2025

This PR enhances Data Connect's emulator.sh script by introducing robust command-line argument parsing. This improves the developer experience when launching the Firebase Data Connect and Authentication emulators for local development, offering easier control over the Data Connect Emulator binary and PostgreSQL database configuration.

This change does not affect customers at all; this script is only used for development of the data connect sdk itself.

Highlights

  • Enhanced Command-Line Argument Parsing: The emulator.sh script now supports command-line arguments (-c, -p, -w, -h).
  • Custom Emulator Binary Support: Users can specify a custom Data Connect Emulator binary path using the -c option, allowing for local development with specific emulator versions.
  • Flexible PostgreSQL Configuration: The PostgreSQL connection string can now be customized via the -p option, enabling connections to different PostgreSQL instances or the use of an ephemeral PGLite server.
  • PostgreSQL Database Management: A new -w option has been added to automatically wipe and restart the local PostgreSQL container before launching the emulators.
  • Improved Script Structure and Help: The script has been refactored into modular functions (main, parse_args, print_help, log) and includes a comprehensive help message accessible via the -h option.

… easier using, especially when using a custom data connect emulator binary.

This comment was marked as off-topic.

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.

Summary of Changes

Hello @dconeybe, 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 significantly enhances the emulator.sh script by introducing robust command-line argument parsing. The primary goal is to improve the developer experience when launching the Firebase Data Connect and Authentication emulators, offering more control over the Data Connect Emulator binary and PostgreSQL database configuration.

Highlights

  • Enhanced Command-Line Argument Parsing: The emulator.sh script now supports command-line arguments (-c, -p, -w, -h) for improved developer experience and flexibility.
  • Custom Emulator Binary Support: Users can specify a custom Data Connect Emulator binary path using the -c option, allowing for local development with specific emulator versions.
  • Flexible PostgreSQL Configuration: The PostgreSQL connection string can now be customized via the -p option, enabling connections to different PostgreSQL instances or the use of ephemeral PGLite servers.
  • PostgreSQL Database Management: A new -w option has been added to automatically wipe and restart the local PostgreSQL container before launching the emulators, streamlining testing and setup.
  • Improved Script Structure and Help: The script has been refactored into modular functions (main, parse_args, print_help, log) and includes a comprehensive help message accessible via the -h option.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 or fill out our survey to provide feedback.

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.

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 improves the developer experience for emulator.sh by introducing command-line argument parsing. The code is well-structured with clear functions.

There are a few suggestions to improve the script's robustness and clarity. There is also a high-severity functional bug where an option doesn't work as documented, and a high-severity issue with misleading documentation for an environment variable. Addressing these points will make the script more reliable and easier to use.

@google-oss-bot

This comment was marked as off-topic.

@google-oss-bot

This comment was marked as off-topic.

@dconeybe
Copy link
Contributor Author

/gemini review

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 significantly improves the emulator.sh script by adding command-line argument parsing and structuring the code into functions. The changes make the script more flexible and user-friendly for developers. My review includes suggestions to enhance the script's robustness, maintainability, and adherence to shell scripting best practices.

@dconeybe dconeybe enabled auto-merge (squash) July 22, 2025 19:04
Copy link

@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 modernizes the Data Connect emulator launch script by replacing a simple static configuration with comprehensive command-line argument parsing. The changes enable developers to customize emulator binary paths, PostgreSQL connections, and database management workflows through command-line options.

  • Replaced hardcoded configuration with -c, -p, -v, -w, and -h command-line options
  • Added modular function structure with main, parse_args, print_help, and log functions
  • Introduced PostgreSQL database management capabilities through the -w option

@dconeybe dconeybe merged commit 0ebb4ab into main Jul 22, 2025
48 checks passed
@dconeybe dconeybe deleted the dconeybe/dataconnect/EmulatorShGetopts branch July 22, 2025 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants