Skip to content

feat: support kebab-case aliases for camelCase subcommands (fixes #32)#34

Closed
jpoehnelt-bot wants to merge 2 commits intogoogleworkspace:mainfrom
jpoehnelt-bot:feat/kebab-case-aliases
Closed

feat: support kebab-case aliases for camelCase subcommands (fixes #32)#34
jpoehnelt-bot wants to merge 2 commits intogoogleworkspace:mainfrom
jpoehnelt-bot:feat/kebab-case-aliases

Conversation

@jpoehnelt-bot
Copy link
Copy Markdown
Contributor

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

$ gws gmail users get-profile --params '{"userId":"me"}'
error: unrecognized subcommand 'get-profile'
  tip: a similar subcommand exists: 'getProfile'

$ gws calendar calendar-list list
error: unrecognized subcommand 'calendar-list'
  tip: a similar subcommand exists: 'calendarList'

After

# camelCase still works (backward compatible)
$ gws gmail users getProfile --params '{"userId":"me"}'   ✓

# kebab-case now works as an alias
$ gws gmail users get-profile --params '{"userId":"me"}'  ✓

# resource aliases work too
$ gws calendar calendarList list                             ✓
$ gws calendar calendar-list list                           ✓

Implementation

  • src/commands.rs — Added camel_to_kebab(), kebab_to_camel(), and resolve_name() utilities. For every Command whose canonical name contains uppercase, a visible_alias() with the kebab-case spelling is registered automatically. This applies to both resource-level and method-level commands, recursively.

  • src/main.rs — Updated resolve_method_from_matches() to pass each path segment through commands::resolve_name() as a defense-in-depth measure (clap already normalises alias lookups to the canonical name, but this ensures robustness). Updated print_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 Covers
test_camel_to_kebab_* utility conversion
test_kebab_to_camel_* utility conversion
test_camel_kebab_roundtrip invertibility
test_resolve_name_* map key resolution
test_gmail_users_get_profile_canonical camelCase still works
test_gmail_users_get_profile_kebab_alias kebab alias registered
test_gmail_users_get_profile_kebab_matches_canonical clap resolves to canonical
test_calendar_calendar_list_canonical resource camelCase works
test_calendar_calendar_list_kebab_alias resource kebab alias registered
test_calendar_calendar_list_kebab_matches_canonical end-to-end match resolution

Quality 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

…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.
@jpoehnelt-bot jpoehnelt-bot requested a review from jpoehnelt as a code owner March 4, 2026 05:00
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 4, 2026

🦋 Changeset detected

Latest commit: 465a82e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@googleworkspace/cli Minor

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

@gemini-code-assist
Copy link
Copy Markdown
Contributor

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 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

  • Kebab-case Aliases: Implemented support for kebab-case aliases for all camelCase API resource and method names, enhancing CLI usability while maintaining backward compatibility.
  • Utility Functions: Added camel_to_kebab, kebab_to_camel, and resolve_name functions to handle string case conversions and name resolution.
  • CLI Command Tree Integration: Automatically registers visible kebab-case aliases for commands whose canonical names contain uppercase letters, applying to both resource and method levels.
  • Robust Name Resolution: Updated the method resolution logic to use the new resolve_name utility, providing a defense-in-depth measure for handling kebab-case inputs.
  • Documentation and Tests: Updated the README.md and print_usage help text to inform users about the new naming convention support, and added comprehensive unit tests for the new functionality.
  • Code Quality Improvements: Fixed 7 pre-existing clippy warnings across various files, improving code consistency and quality.
Changelog
  • @googleworkspace/cli
Activity
  • All 313 existing tests passed successfully.
  • New unit tests were added for camel_to_kebab, kebab_to_camel, camel_kebab_roundtrip, and resolve_name utility functions.
  • Specific end-to-end tests were added for Gmail getProfile and Calendar calendarList aliases to verify correct functionality.
  • Code formatted with cargo fmt --all.
  • Static analysis with cargo clippy --all-targets --all-features -- -D warnings passed, with 7 pre-existing warnings fixed in executor.rs, helpers/chat.rs, helpers/docs.rs, helpers/sheets.rs, and setup.rs.
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.

Copy link
Copy Markdown
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 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.

@jpoehnelt-bot
Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

Copy link
Copy Markdown
Member

@jpoehnelt jpoehnelt left a comment

Choose a reason for hiding this comment

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

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:

  1. resolve_name defence-in-depth — the comment notes this is used as a fallback inside resolve_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.

  2. Acronym handlingcamel_to_kebab treats each uppercase letter independently, so getHTTPSUrl would become get-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.

  3. Naming of resolve_name — the function signature takes mut map_keys but only calls .find() (non-mutating consumption). mut on the parameter is harmless but slightly misleading; map_keys: impl Iterator<Item = &'a String> without mut would be cleaner.

  4. Test structure — the tests in commands.rs are thorough. Consider moving the make_gmail_doc helper to a test_helpers submodule or using #[cfg(test)] gating consistently.

LGTM overall — backward compatible and well-covered.

@jpoehnelt-bot
Copy link
Copy Markdown
Contributor Author

Addressed Gemini review feedback:\n\n- Simplified method resolution in resolve_method_from_matches to directly index by method_key after resolve_name succeeds (removed redundant nested if let).\n\nCommit: 465a82e

@jpoehnelt
Copy link
Copy Markdown
Member

Closing as superseded by PR #41 which implements global kebab-case flag normalization.

@jpoehnelt jpoehnelt closed this Mar 4, 2026
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.

feat: support kebab-case subcommand aliases alongside camelCase

2 participants