A command-line tool for managing tags on Confluence pages in bulk, written in Rust with Nix for environment management.
ctag add "space = DOCS" tag1 tag2 tag3ctag remove "space = DOCS" old-tagctag replace "space = DOCS" old-tag=new-tag another-old=another-new# Show all pages with their tags
ctag get "space = DOCS"
# Show only unique tags
ctag get "space = DOCS" --tags-only
# Output as JSON
ctag get "space = DOCS" --format json
# Save to file
ctag get "space = DOCS" --output-file results.json# Remove all tags starting with "test-tag-"
ctag remove "space = DOCS" "test-tag-.*" --regex# Replace any tag matching "id-[0-9]+" with "matched-id"
# Note: Use positional pairs (pattern replacement pattern replacement ...)
ctag replace --regex "space = DOCS" "id-[0-9]+" "matched-id"
# Multiple replacements
ctag replace --regex "space = DOCS" \
"test-.*" "new-test" \
"id-[0-9]+" "matched-id"Confirm each action before execution:
ctag add "space = DOCS" new-tag --interactivePreview changes without making modifications:
ctag --dry-run add "space = DOCS" new-tagCreate a JSON file with multiple commands:
{
"description": "Quarterly tag updates",
"commands": [
{
"action": "add",
"cql_expression": "space = DOCS AND lastmodified > -30d",
"tags": ["recent", "q4-2024"],
"interactive": false
},
{
"action": "replace",
"cql_expression": "space = DOCS",
"tags": {
"old-tag": "new-tag",
"deprecated": "archived"
},
"interactive": true
},
{
"action": "replace",
"cql_expression": "space = DOCS",
"tags": {
"test-.*": "new-test",
"id-[0-9]+": "matched-id"
},
"regex": true
}
]
}Execute the commands:
ctag from-json commands.jsoncat commands.json | ctag from-stdin-jsonOr:
echo '{"commands":[{"action":"add","cql_expression":"space = DOCS","tags":["test"]}]}' | ctag from-stdin-jsonSee docs/cql-examples.md for more CQL query examples.
cargo testcargo fmtcargo clippyThe project includes a justfile for common tasks:
just build # Build the project
just run # Run the project
just test # Run tests
just fmt # Format code
just check # Run clippyTo build the project using Nix:
nix buildThe binary will be available in ./result/bin/ctag.
Documentation is auto-generated from the source code. To view it:
cargo doc --openSee LICENSE file for details.
This project was migrated from Python to Rust. The CLI interface remains exactly the same, so all existing scripts and workflows should continue to work without modification.
