Open montchr opened 2 months ago
Hey!
Short background about the current implementation: The reason why there is no default repository config is that one may have multiple independent repository configuration for different purposes. I, for example, have one for personal projects on Github, one for work, and one for some random projects I have laying around. This could be done in a single file with multiple trees
, but I like to keep things separated.
But I see the appeal of having a single file containing all repo configuration, thank you for bringing up that use case. Thoughts about the implemenatation:
config.toml
was a little unfortunate in hindsight. The naming kinda clashes with the worktree-specific grm.toml
file that configures grm worktree
behaviour. So if we change this, I'd go with "repo config" instead of "config". So:
GRM_REPO_CONFIG_FILE
$XDG_CONFIG_HOME/grm/repos.toml
--repo-config
as an alias for --config
to grm repos
commands and deprecating --config
../config.toml
fallback is quite weird. As you said, this is a generic filename.GRM_REPO_CONFIG_FILE
would be fine.grm repos
to be directory-dependent.I think the smallest change that would fit your use case would be the $XDG_CONFIG_HOME/grm/repos.toml
fallback, keeping the ./config.toml
fallback for now. So the lookup order would be (using the first one found):
--config
command line parameter./config.toml
$XDG_CONFIG_HOME/grm/repos.toml
The fallback is currently implemented as a simple default value for --config
in clap: https://github.com/hakoerber/git-repo-manager/blob/3a433a1acdf99e4f0bd7e6726ea6a2814f82b26d/src/grm/cmd.rs#L176
The configuration file itself is read here: https://github.com/hakoerber/git-repo-manager/blob/3a433a1acdf99e4f0bd7e6726ea6a2814f82b26d/src/grm/main.rs#L27
Changing the command line parameter to an Option<String>
and doing the fallback processing inside main()
(second link) should do the trick. I might not have time do tackle this in the near future, so if you want, feel free to take a stab at this. I would then add a few tests (the test suite is quite ... special).
I would like to call
grm repos status
without needing to specify-c <path>
every time I want to use a config file that lives outside the current directory.This could be done by reading an environment variable when
-c
is omitted. Something like$GRM_CONFIG_FILE
, maybe. It would also be great ifgrm
looked in a standard default location like$XDG_CONFIG_HOME/grm/config.toml
.These would, of course, be overridden if
-c <path>
was specified. Not sure what the behavior should be if the current directory has aconfig.toml
, but that's a pretty generic filename so perhaps it should be ignored.