feat: support kebab-case aliases for camelCase subcommands (fixes #32)#34
feat: support kebab-case aliases for camelCase subcommands (fixes #32)#34jpoehnelt-bot wants to merge 2 commits intogoogleworkspace:mainfrom
Conversation
…gleworkspace#32) Every API resource and method name that uses camelCase now also accepts its kebab-case equivalent as a visible alias, following the Unix convention used by tools like kubectl. Changes: - commands.rs: add camel_to_kebab() / kebab_to_camel() / resolve_name() utilities; register visible_alias() for every command whose canonical name contains uppercase letters. - main.rs: update resolve_method_from_matches() to normalise path segments via resolve_name() as a defense-in-depth measure; update help text. - README.md: add tip about both casing forms being accepted. - changeset: minor bump for @googleworkspace/cli. Also fixes seven pre-existing clippy -D warnings (bool_assert_comparison, field_reassign_with_default, manual_contains) in executor.rs, helpers/ chat.rs, helpers/docs.rs, helpers/sheets.rs, and setup.rs. Test results: 313 passed, 0 failed.
🦋 Changeset detectedLatest commit: 465a82e The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Summary of ChangesHello, 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 significant usability improvement by allowing users to interact with the CLI using kebab-case for resource and method names, in addition to the existing camelCase. This change makes the command-line interface more intuitive and consistent with common CLI patterns, without breaking existing workflows. The implementation includes new string utility functions and integrates alias registration directly into the command building process, ensuring robust and flexible name resolution. 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 introduces a great usability improvement by adding support for kebab-case aliases for all camelCase subcommands, which improves the command-line experience. The implementation is solid, with new utility functions for case conversion and robust integration into the command building and resolving logic. The addition of comprehensive unit and integration tests ensures the new functionality is reliable and backward compatible. The code quality is high, and I only have one minor suggestion for simplification.
|
/gemini review |
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
jpoehnelt
left a comment
There was a problem hiding this comment.
Clean implementation of kebab-case aliases. The approach of using clap visible_alias is the right one here — it keeps the canonical camelCase name as the source of truth while making the CLI more shell-friendly.
A few observations:
-
resolve_namedefence-in-depth — the comment notes this is used as a fallback insideresolve_method_from_matches. Since clap already normalises aliases to the canonical name, this helper should rarely fire in practice. A test that exercises the full end-to-end path (kebab input → correct HTTP method dispatched) would give more confidence than unit tests on the helper alone. -
Acronym handling —
camel_to_kebabtreats each uppercase letter independently, sogetHTTPSUrlwould becomeget-h-t-t-p-s-url. If any Google API method names contain consecutive uppercase runs, the output may look odd. A quick scan of the discovery docs for such patterns is worth doing. -
Naming of
resolve_name— the function signature takesmut map_keysbut only calls.find()(non-mutating consumption).muton the parameter is harmless but slightly misleading;map_keys: impl Iterator<Item = &'a String>withoutmutwould be cleaner. -
Test structure — the tests in
commands.rsare thorough. Consider moving themake_gmail_dochelper to atest_helperssubmodule or using#[cfg(test)]gating consistently.
LGTM overall — backward compatible and well-covered.
|
Addressed Gemini review feedback:\n\n- Simplified method resolution in |
|
Closing as superseded by PR #41 which implements global kebab-case flag normalization. |
Summary
Closes #32.
Every API resource and method name that uses camelCase is now also accessible via its kebab-case equivalent, registered as a visible alias in the clap command tree. Both forms are always accepted, maintaining full backward compatibility.
Before / After
Before
After
Implementation
src/commands.rs— Addedcamel_to_kebab(),kebab_to_camel(), andresolve_name()utilities. For everyCommandwhose canonical name contains uppercase, avisible_alias()with the kebab-case spelling is registered automatically. This applies to both resource-level and method-level commands, recursively.src/main.rs— Updatedresolve_method_from_matches()to pass each path segment throughcommands::resolve_name()as a defense-in-depth measure (clap already normalises alias lookups to the canonical name, but this ensures robustness). Updatedprint_usage()help text to mention both forms.README.md— Added a tip callout explaining both naming forms are accepted..changeset/feat-kebab-case-aliases.md— Minor version bump for@googleworkspace/cli.Tests
All 313 tests pass. New tests added to
commands::tests:test_camel_to_kebab_*test_kebab_to_camel_*test_camel_kebab_roundtriptest_resolve_name_*test_gmail_users_get_profile_canonicaltest_gmail_users_get_profile_kebab_aliastest_gmail_users_get_profile_kebab_matches_canonicaltest_calendar_calendar_list_canonicaltest_calendar_calendar_list_kebab_aliastest_calendar_calendar_list_kebab_matches_canonicalQuality checks
cargo fmt --all✅cargo clippy --all-targets --all-features -- -D warnings✅(also fixed 7 pre-existing clippy warnings in executor.rs, helpers/chat.rs, helpers/docs.rs, helpers/sheets.rs, setup.rs)
cargo test✅ — 313 passed, 0 failed