crashappsec / con4m

Configuration Language for Mortals

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Option to generate getter and setter methods for everything; setters should update both objects.

viega opened this issue · comments

Clearly can see it will be needed as I do the validation I need to do given there aren't validator callbacks. Specifically, I'm having to add this code to SAMI that should be at most one simple call:

  if config.defaultCmd.isSome() and not config.defaultCmd in allowedCmds:
    warn(fmt"Default command {config.defaultCmd} not recognized (ignored)")
    
    # This dance needs to be automated by con4m.  Note that we are
    # only making a copy of the entry here, so after we edit we need
    # to re-set it.
    var entry = ctxSamiConf.st.entries["default_command"]
    entry.value = none(Box)
    ctxSamiConf.st.entries = entry
    config.defaultCmd = none(string)
    

  if not config.logLevel in validLogLevels:
    warn(fmt"Log level {config.logLevel} not recognized. Defaulting to 'warn'")

    var entry = ctxSamiConf.st.entries["log_level"]
    entry.value = some(Box("warn"))
    ctxSamiConf.st.entries = entry
    config.logLevel = "warn"