Skip to main content

Module conditional_format

Module conditional_format 

Source
Expand description

Conditional formatting via spreadsheets.batchUpdate (issue #1793, ADR-0081 §1).

Three mutating verbs, all gated by DriveOperation::SheetsStructure — presentational, destroys no data, exactly like format-cells/ set-data-validation. list-conditional-formats is a plain read, ungated like list-protections — its own module lives entirely in crate::cli::drive::sheets::conditional_format, this module has no “list” verb of its own. Shape mirrors format.rs/validation.rs/ protection.rs: compose a target, resolve it against a freshly-fetched workbook, gate, dry-run, mutate, log.

Index-addressed, not id-addressed. Unlike a crate::drive::sheets::types::ProtectedRange, a conditional format rule has no stable id — it is one entry of a crate::drive::sheets::types::Sheet’s ordered conditional_formats list, and update-conditional-format/delete-conditional-format’s --index names an ordinal position that shifts when an earlier rule is deleted. list-conditional-formats exists to make that position discoverable immediately before acting on it (the same reason list-protections exists), and --dry-run on update/delete echoes the rule currently at the given index — both states, “currently” and “to” — so a stale index is visible before it’s acted on.

A curated condition/rule surface, not full BooleanRule/GradientRule coverage, mirroring validation.rs’s own stance. FormatCondition is a separate, smaller enum from validation::Condition — duplicated rather than shared, since the two surfaces support an overlapping but different set of condition types: this one drops ONE_OF_LIST/ ONE_OF_RANGE/CHECKBOX (dropdown-only, meaningless for a format trigger) and adds BLANK/NOT_BLANK (--cell-empty/--cell-not-empty, meaningful only as a format trigger). GradientRule’s two endpoints are always anchored MIN/MAX; Sheets also allows an endpoint anchored at an explicit NUMBER/PERCENT/PERCENTILE value, which this crate doesn’t build — docs/drive.md names both gaps. update-conditional-format only replaces the rule at an index; Sheets also supports moving a rule from one index to another without changing its content, which this crate doesn’t build either.

Structs§

ConditionalFormatOptions
Per-call options.
ConditionalFormatOutcome
The full outcome of one attempt.
FormatEffect
The mutable subset of a cell’s format a BooleanRule can apply.
GradientMidpoint
A GradientRule’s optional midpoint.
GradientSpec
A GradientRule this crate can build — see the module doc’s gradient cut for what’s deliberately excluded.

Enums§

ConditionalFormatResult
What happened (or, under --dry-run, would happen).
ConditionalFormatVerb
Which mutation to perform.
FormatCondition
The condition shapes a BooleanRule can trigger on.
FormatRule
The rule content add-conditional-format/update-conditional-format build — exactly one of a condition-triggered format or a color-scale gradient, matching ConditionalFormatRule’s own union.
GradientPointType
One of Sheets’ GradientRule midpoint anchor types — MIN/MAX are reserved for the two fixed endpoints and never appear here (see the module doc’s gradient cut).

Functions§

conditional_format
Runs one conditional-format mutation, logging every attempt that isn’t a dry run.
describe
Renders an outcome as human-readable text.
describe_lines
Renders an outcome as its individual lines, none of which contains a newline.