Skip to content

feat: add --list-files flag and extract header parsing utility#95

Merged
kevmoo merged 1 commit intomasterfrom
cleanup
Mar 15, 2026
Merged

feat: add --list-files flag and extract header parsing utility#95
kevmoo merged 1 commit intomasterfrom
cleanup

Conversation

@kevmoo
Copy link
Owner

@kevmoo kevmoo commented Mar 15, 2026

  • Add -l, --list-files flag to generate a directory listing when no index.html is present.

  • Extract parsing logic for --headers strings into a public parseKeyValuePairs utility in lib/src/utils.dart.

  • Improve --help console output check tests.

  • Update README.md and CHANGELOG.md with recent changes.

- Add `-l, --list-files` flag to generate a directory listing when no `index.html` is present.

- Extract parsing logic for `--headers` strings into a public `parseKeyValuePairs` utility in `lib/src/utils.dart`.

- Improve `--help` console output check tests.

- Update `README.md` and `CHANGELOG.md` with recent changes.
@gemini-code-assist
Copy link

Summary of Changes

Hello, 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 introduces a new command-line option to allow directory listings when a default index file is absent, enhancing the server's flexibility. It also improves the internal architecture by centralizing header parsing logic into a dedicated utility, making the codebase cleaner and more maintainable. Accompanying these functional changes are updates to documentation and an expanded test suite to ensure reliability.

Highlights

  • New Feature: --list-files flag: Introduced a new --list-files flag that enables directory listings when an index.html file is not present in the served directory.
  • Code Refactoring: Header Parsing Utility: Extracted the logic for parsing --headers strings into a public parseKeyValuePairs utility function located in lib/src/utils.dart, improving modularity and reusability.
  • Improved Test Coverage: Enhanced existing tests related to --help console output and added new tests for the listFiles functionality and the extracted header parsing utility.
  • Documentation and Changelog Updates: Updated README.md to reflect the new --list-files flag and clarified the --port option. The CHANGELOG.md was also updated to include these recent changes and the version was bumped to 4.2.0.
Changelog
  • CHANGELOG.md
    • Updated version to 4.2.0.
    • Added entry for --list-files flag.
    • Reordered existing entries for clarity.
    • Updated SDK requirement to ^3.10.0.
  • README.md
    • Updated the description for the --port flag to mention using 0 for a random port.
    • Added documentation for the new --list-files flag.
  • bin/dhttpd.dart
    • Imported lib/src/utils.dart.
    • Replaced internal _parseKeyValuePairs with the public parseKeyValuePairs utility.
    • Passed the new listFiles option to the Dhttpd.start method.
    • Updated the server start message for better clarity.
  • lib/dhttpd.dart
    • Declared Dhttpd as a final class.
    • Added a listFiles boolean parameter to the Dhttpd.start constructor.
    • Configured createStaticHandler to use the listFiles parameter for directory listing.
  • lib/src/options.dart
    • Modified the help text for the --port option.
    • Introduced a new listFiles option with an associated CliOption annotation.
    • Added listFiles to the Options class constructor.
  • lib/src/options.g.dart
    • Updated the help text for the --port option.
    • Added parsing logic for the new --list-files flag.
  • lib/src/utils.dart
    • Added a new file containing the parseKeyValuePairs utility function, which handles parsing of key-value string pairs.
  • pubspec.yaml
    • Updated the package version from 4.2.0-wip to 4.2.0.
  • test/command_test.dart
    • Updated test descriptions for clarity (e.g., '--help' to 'prints help').
    • Adjusted expected console output in tests to match the updated --port help text and the new server start message format.
    • Included the --list-files flag in the expected help output.
  • test/dhttpd_test.dart
    • Added a new test case to verify the functionality of the listFiles option, ensuring directory listings are correctly displayed.
  • test/utils_test.dart
    • Added a new file containing comprehensive unit tests for the parseKeyValuePairs utility function, covering various parsing scenarios and error handling.
Activity
  • No human activity (comments, reviews, etc.) has been recorded for this pull request yet.
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.

@github-actions
Copy link

Package publishing

Package Version Status Publish tag (post-merge)
package:dhttpd 4.2.0 ready to publish v4.2.0

Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation.

Copy link

@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 --list-files flag for directory listings and refactors header parsing into a public utility. The changes are well-implemented with corresponding updates to documentation and tests. I've identified two minor issues related to the use of multiline string literals in Dart, which impact test correctness and error message formatting. My review provides specific suggestions to address these points.

@kevmoo kevmoo merged commit 53a17cc into master Mar 15, 2026
5 checks passed
@kevmoo kevmoo deleted the cleanup branch March 15, 2026 21:44
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.

1 participant