# Demo: rename a tool parameter, everywhere, in one command Renaming a Galaxy tool parameter by hand is a chore *and* a hazard: the name is scattered across the `` (often inside `#if` directives and dotted `$param.metadata.…` accesses), the output `label`s, by-name cross-reference attributes, and the ``. Miss one and the tool silently breaks. The `rename-param` command does it in one shot, **atomically**: it rewrites every real reference or changes nothing. ## 1. A tool that references a parameter all over the place `seqstats.xml`, note `input_bam` appears in a `#if` condition, a dotted `.metadata.bam_index` access, a quoted command argument, the output `label`, the `` definition, and the test: ```xml '$stats_out' ]]> ``` First, see where it's used (read-only, changes nothing): ```console $ galaxy-tool-refactor find-references input_bam seqstats.xml seqstats.xml:3 [command] $input_bam.metadata.bam_index seqstats.xml:4 [command] $input_bam.metadata.bam_index seqstats.xml:6 [command] $input_bam seqstats.xml:17 [output_data_label:stats_out] ${input_bam.name} 4 reference(s) to 'input_bam' across 1 tool(s) ``` ## 2. Rename it: one command ```console $ galaxy-tool-refactor rename-param input_bam aligned_reads seqstats.xml renamed seqstats.xml: 6 site(s) across 1 file(s) renamed 1 tool(s); skipped 0 ``` (Six sites: the three `$`-references, the output label, the `` definition, and the `` reference. Use `--check` first for a dry-run preview that writes nothing, or `--backup` to keep a `seqstats.xml.bak` copy.) ## 3. The result ```diff '$stats_out' ]]> - + - + - + ``` The renamed tool **still validates** (`galaxy-tool-refactor` parses and checks it against the 21.09 schema). Every `input_bam` became `aligned_reads`, and nothing else moved. ## What it got right (and what it deliberately left alone) - **Followed the reference into a `#if` directive** and through a **dotted access** (`$input_bam.metadata.bam_index`), rewriting only the parameter segment, not the `.metadata.bam_index` part. - **Followed it into the output `label`** (`${input_bam.name}` → `${aligned_reads.name}`). - **Renamed the `` reference**: a test references inputs by name, so a rename that forgot it would leave the test pointing at a parameter that no longer exists. - **Left the other parameters alone** (`$region`, `$stats_out`). - **Left the shell variable `${GALAXY_SLOTS:-1}` alone**: it is not a Galaxy parameter. And it is careful by construction. `rename-param` is built on a *faithful* Cheetah lexer, so it never rewrites a `$input_bam` that appears inside a `#raw` block, a `##` comment, or an escaped `\$input_bam`: those are not live references. It also does **not** touch `` text, because help is rendered documentation (RST/Markdown), not a Cheetah-templated section. ## Following the parameter into an output `` An output `` is a **Python expression**, so it names a parameter by *bare* word: `output_format == "ppm"`, not `$output_format`. That used to make a rename **bail**: the engine couldn't prove a bare-name rewrite safe without a Python tokeniser. It now uses one. Take the real IUC tool [`pdfimages`](https://github.com/galaxyproject/tools-iuc/tree/main/tools/pdfimages): `output_format` is a `