Refactor CLI tunnel service and authorized fetch options#575
Refactor CLI tunnel service and authorized fetch options#575dahlia merged 4 commits intofedify-dev:mainfrom
Conversation
Since showChoices: true is set in the runner configuration, the choice() value parser automatically appends the list of valid tunnel service options to the help text. Manually listing them via valueSet() in the description was redundant.
The `tunnelServiceOption` constant in `options.ts` has been replaced with a `createTunnelServiceOption()` factory function that accepts an optional list of option names. This allows the tunnel command to reuse the shared option configuration while adding its own short aliases (`-s`, `--service`) without duplicating the option logic. The hardcoded default value of `"localhost.run"` has also been removed from the config binding, delegating the fallback behavior to the tunneling implementation, which can randomly select a service when none is specified.
Wrap the `authorizedFetchOption` object parser with Optique's `withDefault()` instead of supplying fallback values through `bindConfig`'s `default` parameter. As a result, `--first-knock` and `--tunnel-service` are now rejected when provided without the `-a`/`--authorized-fetch` flag, giving clearer validation errors on misuse. The test suite is expanded to cover additional scenarios: - Parsing without `-a` using `setActiveConfig` directly (without the async config-loading path) - Config-driven authorized fetch enablement - Reading `firstKnock` value from config - Rejection of `--first-knock` without `-a` - Rejection of `--tunnel-service` without `-a` Co-Authored-By: Codex <codex@openai.com>
Summary of ChangesHello @dahlia, 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 refactors key command-line interface (CLI) option parsers within the Highlights
Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request is a solid refactoring of CLI options, improving code reuse with the createTunnelServiceOption factory and enhancing validation for authorizedFetchOption using withDefault. The expanded test suite is a valuable addition. I have two suggestions: one to simplify a configuration key for better clarity, and another to correct what appears to be a mistaken assertion in a new test.
Codecov Report❌ Patch coverage is
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
sij411
left a comment
There was a problem hiding this comment.
Looks cleaner than before
This PR refactors two related CLI option parsers in the
@fedify/clipackage and upgrades Optique to 0.10.6.createTunnelServiceOption()factory functionThe former
tunnelServiceOptionconstant is replaced by acreateTunnelServiceOption()factory function. Previously, thelookupcommand and thetunnelcommand each defined their own tunnel service option independently, leading to duplicated logic. The factory accepts an optional list of option names (defaulting to["--tunnel-service"]), so thetunnelcommand can reuse the same definition under its-s/--servicealiases without copy-pasting.The default value is also changed from the hard-coded
"localhost.run"toundefined. The tunneling implementation already handles theundefinedcase by randomly selecting a service, so the old default was masking that behavior rather than expressing intent.The description of the
--tunnel-serviceoption no longer redundantly lists all available service names inline; the metavarSERVICEand the config file documentation are sufficient.authorizedFetchOptionwithwithDefaultauthorizedFetchOptionis now wrapped with Optique'swithDefault()instead of relying on each field'sbindConfigdefaultparameter. As a result,--first-knockand--tunnel-serviceare rejected when provided without the-a/--authorized-fetchflag, giving clearer validation errors on misuse.The test suite for
authorizedFetchOptionis expanded to cover:-aviasetActiveConfigdirectlyfirstKnockfrom config--first-knockwithout-a--tunnel-servicewithout-aOptique 0.10.6
Updates
@optique/coreand@optique/runto 0.10.6 acrossdeno.json,pnpm-workspace.yaml, and the lock files.