Skip to content

feat: add a root --version CLI flag#214

Merged
timlaing merged 2 commits intotimlaing:mainfrom
MrJarnould:codex/cli-version-flag-clean
Apr 3, 2026
Merged

feat: add a root --version CLI flag#214
timlaing merged 2 commits intotimlaing:mainfrom
MrJarnould:codex/cli-version-flag-clean

Conversation

@MrJarnould
Copy link
Copy Markdown

Proposed change

This PR adds a root-level --version flag to the icloud CLI.

Running icloud --version now prints the installed pyicloud package version and exits without requiring a subcommand. The implementation resolves the version from installed package metadata so the output matches the actual installed distribution rather than a hard-coded string.

This keeps the change small and focused:

  • add a root CLI callback for --version
  • print the installed pyicloud version and exit early
  • add a focused CLI test covering the new flag

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New service (thank you!)
  • New feature (which adds functionality to an existing service)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests
  • Documentation or code sample

Example of code:

# CLI usage
# icloud --version

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Local validation:
    • uv run --no-sync python -m pytest tests/test_cmdline.py -q
    • uv run --no-sync ruff check pyicloud/cli/app.py tests/test_cmdline.py
    • uv run --no-sync python -m pyicloud.cmdline --version -> 2.4.2.dev11

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

  • Documentation added/updated to README

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 31, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: eeb8b9b7-7a46-4472-b437-c309deea82a1

📥 Commits

Reviewing files that changed from the base of the PR and between 404b0d7 and 8344099.

📒 Files selected for processing (2)
  • pyicloud/cli/app.py
  • tests/test_cmdline.py

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Users can now display the installed CLI version using the --version flag, providing quick access to version information without running other commands.
    • The version flag is processed immediately when invoked.
  • Tests

    • Added test coverage to verify the version flag displays the correct package version.

Walkthrough

Added version display functionality to the pyicloud CLI application. A new --version flag is introduced via a root Typer callback with an eager option handler that retrieves and prints the installed package version before subcommand dispatch.

Changes

Cohort / File(s) Summary
CLI Version Handling
pyicloud/cli/app.py
Added _installed_version() helper to retrieve package metadata and _version_callback() to handle --version flag display. Registered a new root Typer callback with eager version option to intercept version requests before subcommand processing.
CLI Version Test
tests/test_cmdline.py
Added test_root_version_prints_installed_package_version to verify the --version flag outputs the correct version string and exits successfully.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A whisker of wisdom, now bundled and bright,
The version flag hops into glorious sight!
With metadata magic and callbacks so keen,
Our CLI now proudly shows what it's been!
Hop, hop—test it true, all problems take flight! 🐇✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: add a root --version CLI flag' is clear, concise, and directly describes the main change—adding a --version flag to the CLI.
Description check ✅ Passed The description is well-detailed and directly related to the changeset, explaining the proposed change, implementation, and validation steps performed.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Pylint (4.0.5)
tests/test_cmdline.py
pyicloud/cli/app.py

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@timlaing timlaing self-assigned this Apr 3, 2026
@timlaing timlaing added the enhancement New feature or request label Apr 3, 2026
@timlaing timlaing merged commit 61b2524 into timlaing:main Apr 3, 2026
11 of 14 checks passed
@timlaing
Copy link
Copy Markdown
Owner

timlaing commented Apr 3, 2026

@MrJarnould - thanks for this update

timlaing added a commit to MrJarnould/pyicloud that referenced this pull request Apr 3, 2026
Co-authored-by: Tim Laing <11019084+timlaing@users.noreply.github.com>
timlaing added a commit that referenced this pull request Apr 3, 2026
* feat: add CLI support for Notes and Reminders

* fix: repair Notes folder desired keys

* fix: derive reminder list counts from membership

* fix: speed up Notes sync and fix Reminders hashtag round-trips

* docs: use installed icloud CLI in README examples

* fix: address Notes and Reminders CLI review nits

* Update permissions for autolabeler workflow

Signed-off-by: Tim Laing <11019084+timlaing@users.noreply.github.com>

* Fix formatting in autolabeler workflow by removing unnecessary blank line

* feat: add a root --version CLI flag (#214)

Co-authored-by: Tim Laing <11019084+timlaing@users.noreply.github.com>

* fix: restore SMS and trusted-device 2FA auth flows (#210)

* feat: handle Apple's HSA2 trusted-device prompts

* Trim unrelated Notes PR scope

* Address CodeRabbit review comments

* Add docstrings for auth bridge PR scope

* Harden bridge prover and persistence tests

* Update protobuf requirement from <7,>=6.31.1 to >=6.31.1,<8 (#208)

Updates the requirements on [protobuf](https://github.com/protocolbuffers/protobuf) to permit the latest version.
- [Release notes](https://github.com/protocolbuffers/protobuf/releases)
- [Commits](https://github.com/protocolbuffers/protobuf/commits)

---
updated-dependencies:
- dependency-name: protobuf
  dependency-version: 7.34.1
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump github/codeql-action from 4.34.1 to 4.35.1 (#209)

Bumps [github/codeql-action](https://github.com/github/codeql-action) from 4.34.1 to 4.35.1.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](github/codeql-action@3869755...c10b806)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 4.35.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* refactor: remove obsolete 2FA tests for trusted device and SMS flows

---------

Signed-off-by: Tim Laing <11019084+timlaing@users.noreply.github.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Tim Laing <11019084+timlaing@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants