Skip to content

Conversation

@sg-qwt
Copy link
Contributor

@sg-qwt sg-qwt commented Oct 22, 2025

Add :config-file cli option

  • I added a entry in changelog under unreleased section.

Comment on lines 4 to 11
1. base: fixed config var `eca.config/initial-config`.
2. env var: searching for a `ECA_CONFIG` env var which should contains a valid json config.
3. local config-file: searching from a local `.eca/config.json` file.
4. `initializatonOptions` sent in `initialize` request."
4. `initializatonOptions` sent in `initialize` request.
When a `ECA_CONFIGFILE` env var set, it takes precedence and we only deep merge:
1. base: fixed config var `eca.config/initial-config`.
2. env file: searching for a `ECA_CONFIGFILE` env var which points to a json config file."
Copy link
Member

Choose a reason for hiding this comment

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

I think we should just mention the env var in the existing waterfall, something like, maybe just add between 2 and 3?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My original imp was to snug that into waterfall between 3/4. But then I realized that didn't make sense. When user supplied explicit config path to the config file, I don't think he'd (at least myself this case) expect that to be merged with local/home config in the waterfall.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For example, I generated some eca config using home-manager. Then I go
ECA_CONFIGFILE=/nix/store/xxx/my.json eca server
That my.json is my exact pure config to start the server, I wouldn't expect it to be further merged with other stuff this case..

Copy link
Member

Choose a reason for hiding this comment

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

I see your case, but:

  • it's just easier to understand the waterfall with dumb logics like merging all posibilities, it's way easier to explain to users how that works
  • I don't see why limit to not supporting passing 2 envs and merging them

It might be uncommon, but not impossible, if that makes code even easier to understand/maintain, I'd take that

Copy link
Contributor Author

@sg-qwt sg-qwt Oct 22, 2025

Choose a reason for hiding this comment

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

image I can add 2 into the below case, so that when ECA_CONFIG and ECA_CONFIG_FILE both set, they get merged?

But the point is, when there is a option to set config explicitly, people usually expect it to be a replace logic instead of going down waterfall with local config.

For example, bb --config xxxx
--config <file> Replace bb.edn with file. Defaults to bb.edn adjacent to invoked file or bb.edn in current dir. Relative paths are resolved relative to bb.edn.

That means I want a explicit config to run with bb, not using my home config or what other config.

https://github.com/search?q=MANGOHUD_CONFIGFILE+NOT+is%3Afork+language%3ANix+&type=code
People set the config via that var to replace, not to go through the waterfall.

Or maybe we shall move ECA_CONFIG outside of the waterfall on top like this?
image

What do you think? This might be the best I think.

Copy link
Contributor Author

@sg-qwt sg-qwt Oct 22, 2025

Choose a reason for hiding this comment

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

Well, a slight mod. I think initializationOptions shall always go last on both cases, so it shall be something like this:

The top is the normal local case go through local config->home config chain, the bottom is the explicit set case:
image

Copy link
Member

Choose a reason for hiding this comment

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

I'd still stick with a simple waterfall merge, config waterfalls not overwriting other configs is common, if we want to overwrite we should support in other way like cljfmt with extra-indents option not overriidng indents and so on.

Copy link
Member

Choose a reason for hiding this comment

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

Check this comment I may have misunderstood the feature

CHANGELOG.md Outdated

## Unreleased

- Add `ECA_CONFIGFILE` env var to allow point config file explicitly.
Copy link
Member

Choose a reason for hiding this comment

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

Can we call it ECA_CONFIG_FILE please?

@ericdallo
Copy link
Member

@sg-qwt the feature looks good, just small changes requested

@sg-qwt sg-qwt marked this pull request as draft October 23, 2025 11:30
@sg-qwt sg-qwt changed the title Add a env var ECA_CONFIGFILE option to pass in config file Add :config-file cli option Oct 25, 2025
@sg-qwt sg-qwt marked this pull request as ready for review October 25, 2025 17:44
@sg-qwt
Copy link
Contributor Author

sg-qwt commented Oct 25, 2025

@ericdallo pls check the new imp with cli option

Copy link
Member

@ericdallo ericdallo left a comment

Choose a reason for hiding this comment

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

Looks good! just a small thing about naming

@sg-qwt
Copy link
Contributor Author

sg-qwt commented Oct 25, 2025

Fixed the naming.


(def cli-spec
{:order [:help :version :verbose]
{:order [:help :version :verbose :config-file]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ericdallo I noticed you left out --log-level in cli print, is that by design?

Copy link
Member

Choose a reason for hiding this comment

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

I think I missed that!

Copy link
Member

@ericdallo ericdallo left a comment

Choose a reason for hiding this comment

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

Looks great! thank you!

@ericdallo ericdallo merged commit d5e2e12 into editor-code-assistant:master Oct 25, 2025
7 of 8 checks passed
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