Skip to content

feat(docs): add +page-setup helper#688

Open
jonathanlinford wants to merge 4 commits intogoogleworkspace:mainfrom
jonathanlinford:feat/docs-page-setup
Open

feat(docs): add +page-setup helper#688
jonathanlinford wants to merge 4 commits intogoogleworkspace:mainfrom
jonathanlinford:feat/docs-page-setup

Conversation

@jonathanlinford
Copy link
Copy Markdown

Summary

  • Adds a new docs +page-setup helper command that configures document page properties via updateDocumentStyle batchUpdate
  • Supports --mode (pages/pageless), --orientation (portrait/landscape), --paper-size (letter, a4, legal, etc.), --margin-top/bottom/left/right (inches), and --page-color (hex)
  • Converts user-friendly values (inches, paper size names, hex colors) into the API's internal representation (points, explicit dimensions, RGB floats, field masks)

Examples

gws docs +page-setup --document DOC_ID --paper-size a4 --orientation landscape
gws docs +page-setup --document DOC_ID --margin-top 0.5 --margin-bottom 0.5
gws docs +page-setup --document DOC_ID --page-color '#f0f0f0'
gws docs +page-setup --document DOC_ID --mode pageless

Test plan

  • Unit tests for paper size point conversion (all 11 sizes + unknown)
  • Unit tests for hex color parsing (with/without #, invalid length, invalid chars)
  • Unit tests for request building (paper size, orientation, margins, page color, mode)
  • Unit tests for combined field mask generation
  • Unit tests for error on no properties specified
  • Unit tests for command registration
  • CI: cargo clippy and cargo test pass

🤖 Generated with Claude Code

…erties

Adds a new `docs +page-setup` helper command that builds an
`updateDocumentStyle` batchUpdate request from user-friendly flags:
--mode (pages/pageless), --orientation, --paper-size, --margin-*,
and --page-color.
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 7, 2026

🦋 Changeset detected

Latest commit: 58d1415

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

@google-cla
Copy link
Copy Markdown

google-cla bot commented Apr 7, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@googleworkspace-bot googleworkspace-bot added the area: core Core CLI parsing, commands, error handling, utilities label Apr 7, 2026
@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 new helper command to the Google Workspace CLI that simplifies the process of updating document page styles. By abstracting the complex batchUpdate API requirements, users can now easily adjust page layout settings such as margins, orientation, and background color using intuitive command-line arguments. The implementation includes necessary validation and conversion logic to ensure inputs are correctly translated into the format expected by the Google Docs API.

Highlights

  • New CLI Command: Added a new docs +page-setup helper command to the Google Workspace CLI, allowing users to configure document page properties directly from the command line.
  • Configuration Support: The new command supports setting document mode (pages/pageless), orientation, paper size, margins, and background color.
  • Data Conversion: Implemented robust conversion logic to map user-friendly inputs like inches, paper size names, and hex colors into the required API formats (points, RGB floats, and field masks).
  • Comprehensive Testing: Added extensive unit tests covering paper size conversions, hex color parsing, request building, and command registration.
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.

Footnotes

  1. Review the Generative AI Prohibited Use Policy, 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 the docs +page-setup helper command to the Google Workspace CLI, allowing users to configure document properties such as page orientation, paper size, margins, and background color. The implementation includes hex color parsing, paper size mapping, and integration with the Google Docs batchUpdate API. Feedback was provided to replace an unwrap() call with explicit error handling to prevent potential panics if the supported paper sizes list becomes desynchronized.

@googleworkspace-bot
Copy link
Copy Markdown
Collaborator

/gemini review

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 the +page-setup helper for the docs command, allowing users to configure document properties such as page orientation, paper size, margins, and background color. The implementation includes a new subcommand, helper functions for unit conversions and color parsing, and expanded unit tests. Feedback was provided regarding the detection of the dry-run flag, which is currently being checked on subcommand matches instead of the parent command matches, potentially leading to the flag being ignored.

@googleworkspace-bot
Copy link
Copy Markdown
Collaborator

/gemini review

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 the docs +page-setup helper command to the Google Workspace CLI, enabling users to configure page mode, orientation, paper size, margins, and background colors for Google Docs. The implementation includes utility functions for paper size mapping and hex color parsing, alongside a refactor of the DocsHelper to accommodate multiple subcommands using the batchUpdate API. Feedback focuses on improving the maintainability of the subcommand handling logic and refining the field masks used in the API requests to ensure that only intended properties are updated, preventing the accidental reset of other document style attributes.

@googleworkspace-bot
Copy link
Copy Markdown
Collaborator

/gemini review

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 new +page-setup helper command for Google Docs, allowing users to configure document mode, orientation, paper size, margins, and background color through the CLI. The implementation includes utility functions for paper size mapping and hex color parsing, updates to the command-line interface, and logic to generate the appropriate batchUpdate requests for the Google Docs API. Comprehensive unit tests have been added to verify the new functionality. I have no feedback to provide.

@jonathanlinford
Copy link
Copy Markdown
Author

@jpoehnelt this is ready for review when you get a chance. Gemini bot comments have been addressed — two field mask suggestions were applied, the rest declined with explanations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: core Core CLI parsing, commands, error handling, utilities

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants