Skip to content

feat: add CLI read-only mode (--read-only / REDMINE_READ_ONLY / read_only)#137

Merged
aarondpn merged 6 commits into
aarondpn:mainfrom
sanak:feat/read-only-mode-upstream
Jul 20, 2026
Merged

feat: add CLI read-only mode (--read-only / REDMINE_READ_ONLY / read_only)#137
aarondpn merged 6 commits into
aarondpn:mainfrom
sanak:feat/read-only-mode-upstream

Conversation

@sanak

@sanak sanak commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds an opt-in read-only mode to the CLI, complementing the read-only gating that already exists in the MCP layer. When enabled, any mutating HTTP request is refused before it is sent, so the tool can be pointed at a production Redmine for safe browsing/scripting.

How it works

  • Enforced at the HTTP transport (readOnlyTransport RoundTripper): only GET/HEAD/OPTIONS pass; anything else returns ErrReadOnly without hitting the network. A single choke point means new commands are covered automatically.
  • Three ways to enable, precedence flag > env > config:
    • --read-only global flag
    • REDMINE_READ_ONLY environment variable
    • per-profile read_only: in the config file
  • Backward compatible: default off; no behavior change for existing users.

Tests

  • internal/api/read_only_test.go — transport refuses mutating methods, allows reads.
  • internal/cmdutil/factory_test.go — flag/env/config precedence.
  • internal/config/config_test.goREDMINE_READ_ONLY override.

go build, go vet, gofmt, and full go test ./... all pass on top of current main (including #134/#135).

Notes

The docs site (docs/) is not updated in this PR — happy to add a page if you'd like it.

aarondpn added 3 commits July 20, 2026 19:30
Show the read-only flag in 'redmine config' (table and JSON), name all
three activation sources in the ErrReadOnly message, fix the --read-only
help text (OPTIONS is also allowed), and extend test coverage to PUT,
DELETE, raw PATCH, and the config-file-only and env-disables-config
precedence paths.
Add a read-only mode section to the configuration guide (flag, env var,
per-profile setting, precedence), list --read-only and REDMINE_READ_ONLY
in the flag and env tables, and cross-reference the HTTP-layer guarantee
from the AI agents guide.
@aarondpn
aarondpn merged commit 1235a63 into aarondpn:main Jul 20, 2026
6 checks passed
@aarondpn

Copy link
Copy Markdown
Owner

Thanks for opening the PR, I have released it with https://github.com/aarondpn/redmine-cli/releases/tag/v2.10.0

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.

2 participants