Skip to content

Add "except" for "include"#12

Merged
tuckermcclure merged 3 commits into
mainfrom
tucker/exceptions
Apr 13, 2026
Merged

Add "except" for "include"#12
tuckermcclure merged 3 commits into
mainfrom
tucker/exceptions

Conversation

@tuckermcclure
Copy link
Copy Markdown
Member

This adds the ability to include a file but then overwrite specific fields. The syntax is "Include this file, except that the following items should have the given values...."

include:
  source: roses.yaml
  except:
    - path: rosaceae.malus
      value:
        - domestica
        - fusca
    - path: rosaceae.aruncus # This isn't in roses.yaml, but we're allowed to add stuff.
      value:
        - dioicus

This is all done at the dictionary level, before we start converting to the Julia types. This means that types that "have fields that get overwritten" don't actually need to be mutable, because it all happens before the type is constructed anyway.

Right now, if any part of the path is invalid, it's an error. I don't want to add keys or add new dictionaries to the tree. If a part of the path isn't found, that's more likely to be a typo than something the user means to add/change.

The syntax could go further in the future.

E.g.:

source: default_world.yaml
except:
  - path: "world.vehicles[1].aircraft" # We could add syntax for [\d+] and overwrite that part of the array.
    value: ...

And:

source: whatever.yaml
except:
  - path: "a.b.c"
    remove: true # This could delete the "c" key from "a.b".

And:

source: whatever.yaml
except:
  - path: "a.b.c"
    value: "a value for c"
    add: true # Maybe a, b, or c doesn't exist. This says, "Make them exist."

Copy link
Copy Markdown
Member

@CarlOlsson CarlOlsson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Tested it in cascade, works great. There is some stuff that is commented out, was that just for testing and it should be brought back in?

@tuckermcclure tuckermcclure merged commit 102606b into main Apr 13, 2026
3 checks passed
@tuckermcclure tuckermcclure deleted the tucker/exceptions branch April 13, 2026 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants