Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User-level config files in $HOME directory. #213

Open
artem-zinnatullin opened this issue Mar 25, 2018 · 3 comments
Open

User-level config files in $HOME directory. #213

artem-zinnatullin opened this issue Mar 25, 2018 · 3 comments
Assignees
Milestone

Comments

@artem-zinnatullin
Copy link
Contributor

As we're making Mainframer OS-wide tool #185, we need to add support for configuration files stored in user-home $HOME directory that will be used in case when work-dir doesn't have them.

Purpose of this feature is to enable use cases like:

$ git clone newproject
$ cd newproject
$ mainframer make build

When you have project(s) you don't want to configure specifically and just let Mainframer do its work with 0-setup on project level.

Current plan:

  • Use ~/.mainframer folder as user-home level folder for config files (config, ignore, localignore, remoteignore)
  • Currently we don't plan to merge user-level and project-level configs, project-level will always be prioritized and used instead

There is an existing PR #189 that was targeting 2.x version of Mainframer and not fully compatible with 3.x rewritten in Rust, so we'll merge parts of #189 (specifically integration tests) and add another PR to implement this functionality in Mainframer.

@ming13 do you agree with details like ~/.mainframer as folder name and non-merge behavior?

@arturdryomov
Copy link
Contributor

Please don’t forget about XDG_CONFIG (Linux-specific).

On other note, I think we should actually merge configs like Git does. Take global first, merge with local and use the result. It is not that hard actually, especially since we have a real programming language to use.

@Pozzoooo
Copy link

Pozzoooo commented Apr 1, 2018

@ming13 The integration tests are actually testing properly merged config file like you described, though for the ignore files it is using the local and fall backing for the shared ones, so no merge tests for ignores.

Also, there is a small challenge on this approach, as user could run mainframer at any folder, it might happen to run in the wrong folder.
It happened to me some times, I end up syncing stuff I didn't wanted to, and just realize it after the command fail as there was no "gradlew" or something like this (it happend some times on home folder, just terrible 😆 ).
I've tested a few ideas on my fork, the one I liked the most so far is prompt the user to confirm when it is happen to be a new folder.

@artem-zinnatullin
Copy link
Contributor Author

Merging is not that easy tho, specifically because we don't have a format to unignore stuff like git does:

.idea
!.idea/codeStyleSettings.xml

artem-zinnatullin added a commit that referenced this issue Feb 1, 2019
Closes #225, part of #213 

This change switches config format that used to be some sort of `.ini` file to [YAML](http://yaml.org/spec/1.2/spec.html#id2760395) as discussed in #225 

Example of `.mainframer/config.yml`:

```yml
remote:
  host: "computer1"
  user: "user1" # Not implemented yet.
  port: 1234    # Not implemented yet.
push:
  compression: 5
pull:
  compression: 2
```

---

Code is also getting ready for config files merging #213. 

- `IntermediateConfig` represents one of possibly multiple config files, thus everything is optional.
- `Config` represents finalized config, thus only actually optional fields are optional

Note that `remote.user` and `remote.port` are not implemented yet (we continue to rely on `~/.ssh/config` read by `ssh` for now
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants