feat: add support for -c/--config to override individual config items #1137
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.
This PR introduces support for
-c
/--config
so users can override individual config values on the command line using--config name=value
. Example:Making it possible to set arbitrary config values on the command line results in a more flexible configuration scheme and makes it easier to provide single-line examples that can be copy-pasted from documentation.
Effectively, it means there are four levels of configuration for some values:
model
currently defaults too4-mini
)config.toml
(e.g., user could override the default to bemodel = "o3"
in theirconfig.toml
)-c
or--config
to overridemodel
(e.g., user can include-c model=o3
in their list of args to Codex)-c
(e.g., user can specify--model o3
in their list of args to Codex)Now that it is possible to specify anything that could be configured in
config.toml
on the command line using-c
, we do not need to have a custom flag for every possible config option (which can clutter the output of--help
). To that end, as part of this PR, we drop support for the--disable-response-storage
flag, as users can now specify-c disable_response_storage=true
to get the equivalent functionality.Under the hood, this works by loading the
config.toml
into atoml::Value
. Then for eachkey=value
, we create a small synthetic TOML file withvalue
so that we can run the TOML parser to get the equivalenttoml::Value
. We then parsekey
to determine the point in the originaltoml::Value
to do the insert/replace. Once all of the overrides from-c
args have been applied, thetoml::Value
is deserialized into aConfigToml
and then theConfigOverrides
are applied, as before.