Repository navigation
Settings file: CONFIGEXPORT and CONFIGIMPORT (portable TOML config) - #25
Merged
Merged
Conversation
One flat TOML file carries the interface preferences, the Options profile, the drawing settings (units, LTSCALE, CELWEIGHT, LWDEFAULT, DIMSCALE, CANNOSCALE…), the layouts' plot settings and the command aliases. Export writes it; import applies every entry the existing checks accept and lists the rest. The file is untrusted: capped at 256 KB, parser nesting limited, not-TOML refused whole, SAVEFILEPATH never read or written. Ribbon: Manage › Customization › Import/Export Settings, new icons; Tools menu entries; it/zh translations; docs/config-file.md; tests for the round trip, hostile files and the docs example. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…CHANGELOG and translations Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Portable settings file (CONFIGEXPORT / CONFIGIMPORT)
Community request "Portable Config File": one flat text file that sets up the environment (lineweights, plot styles, aliases, theme, scale, grid, units), easier to carry around than a template.
What it does
icons.rs); menu: Tools › Import Settings… / Export Settings….[interface]: theme, colours, language, interface size, autosave (the OPTIONS JSON form's camel-case names; applied by the app);[profile]: the Options profile variables (OSMODE, GRIDUNIT, SNAPUNIT, PICKBOX, MEASUREINIT…);[drawing]: MEASUREMENT, INSUNITS, LUNITS/LUPREC/AUNITS/AUPREC, ANGBASE, LTSCALE, CELWEIGHT, LWDEFAULT, DIMSCALE, TEXTSIZE, CANNOSCALE (current drawing, one undo step);[plot]: plotStyleTable, displayPlotStyles, plotTransparency, lineweights (every layout of the current drawing);[aliases]:ALIAS = "command"(added like ALIASEDIT's).docs/config-file.md(a test imports that example and expects no issues). CHANGELOG line under Unreleased › New.Why these names
AutoCAD has no single command for this: it keeps the profile in the registry (Options › Profiles exports
.arg), aliases in a.pgpfile and drawing settings in templates. The names follow AutoCAD'snoun + IMPORT/EXPORTpattern (PDFIMPORT, …);CONFIGalone was an old configuration command, so the prefix doesn't clash with anything current.Format
TOML: no settings code used TOML yet (the profile is JSON in eframe storage), but TOML is the flat, commented, hand-editable format the request asked for. The
tomlcrate (MIT/Apache, already inCargo.lockas a transitive dependency) parses it; values are converted to JSON and go through the existing checks (sysvars::set,options::parse_ui,alias_name/command_id, page setup fields), so nothing new decides what a valid value is.Robustness (the file is hostile input)
capped_read, refuses devices/FIFOs); not UTF-8 or not TOML → refused as a whole with the line number, nothing changes.tomlparser (depth 80): tests feed 100 000 nested arrays and inline tables.issues), the rest is applied; at most 20 000 entries read and 100 issues listed.SAVEFILEPATHis neither written nor read: a folder on one computer, and a file from someone else must not move the autosaves.unwrap/expect/panics in non-test code; works on wasm (export downloads the file, import takestext).Behaviour notes
configexport {file?}→{text, settings, file?},configimport {file? | text? | settings?}→{applied, issues, message}. Without the app (CLI, MCP alone) the[interface]section comes back asinterfaceinstead of being applied.[interface](Session::config_interface).[drawing]/[plot]change the open drawing (MEASUREINIT covers new drawings).Tests
crates/engine/tests/config_file.rs: export→import round trip into a fresh session gives the same settings (and one undo step), plot settings on every layout, unknown/invalid entries reported with the rest applied, hostile files refused, no drawing open, interface section hand-back, typed command line, docs example.config.rsunit tests: TOML⇄JSON, line numbers, size and nesting limits.options.rs: interface round trip between two apps, bad interface entries.Possible follow-ups (not in this PR)
<settings folder>/draftcraft.tomlautomatically at startup.[drawing]defaults to new drawings started without a template.🤖 Generated with Claude Code