Reference › Commands › Refactor

Reference › Commands

Refactor

The rewrites that change how a model is written but not what it means.

Commands: archec refactor

Rewrites that keep the project the same: each one writes nothing unless the project builds the same. The old names (archec move-traces, archec name-components, archec translations, archec extract-component) still run, with a note.

Command What it does
archec refactor translations <main.arche> --extract <lang> [-o file] [--dry-run] The inline translations of a language ("Démarrer" en "Start") moved into one translations en { … } file, included by the main file, so the model's files read in one language. A text is named by its place (REQ-1.text) or, when no path names it (a sequence step, a branch, a procedure), by what it says ("texte" "text"); entries are grouped under the file they come from. A text stays where it is when it has several languages, or when the same words are also written without a translation (an entry by its words would translate them too). Written only if the project builds the same.
archec refactor name-components <main.arche> [--dry-run] A component an import named by its Arche id (c-1793752253957) gets a name from its label — component flash_memory "FLASH_MEMORY" as c-1793752253957 — and every path that names it says the name; the id stays Arche's. Written only if the project builds the same.
archec refactor move-traces <main.arche> [--dry-run] [--list] Each trace written apart, moved to where it starts — verifies on the case, the plan or the scenario, satisfies on the part, refines on the requirement — with its id (verifies REQ-1 as t-7); an address written as a string becomes a path when it names something of the project. Written only if the project builds the same traces; --list says why each other one stays.
archec refactor extract-component <main.arche> <A.b> [--name Def] [--also A.c,A.d] [--folder dir] [--dry-run] A component moved into the component library: a folder of its own, copyable into other projects; nothing changes unless the project builds the same.
archec refactor move-definition <main.arche> <Name> --to <file.arche> [--kind component] [--dry-run] A top-level definition — a component, a message, a struct, an enum, a type, an interface, a const, a requirement, a system… — cut from its file with its /// lines and written at the end of another file, or in a new one. include "<file>" is added when the main file does not reach the target yet: in the file the definition was in, or in the main file when the target itself includes that file (no include cycle). A definition of a package is written inside package <name> { … } in the target, so it keeps its package. A file of a library, of the store or of the standard library is neither moved from nor written to. The project is compiled as it is and as it would be, in memory: the same declarations, the same errors and warnings, the same project built (the order of its elements follows the files, and may change) — or nothing is written and the first difference is said: a code "x.py" moved to another folder would name another file, a requirement would leave the defaults of its file, a file the project does not include yet would bring its own declarations. --kind says which when two kinds share the name; --dry-run prints the diff. The generated code needs nothing: a USER CODE region is named after the element, not its file. In VS Code: right-click → Move Definition to a File…, in the editor (on the definition or on a use of it) and on a block of the diagram.