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

Runtime-configurable responses? #10

Open
GoldsteinE opened this issue Dec 23, 2022 · 9 comments
Open

Runtime-configurable responses? #10

GoldsteinE opened this issue Dec 23, 2022 · 9 comments

Comments

@GoldsteinE
Copy link

Hi! It would be fun if cargo-mommy supported runtime loading responses.json with custom responses.

@VixieTSQ
Copy link
Contributor

Would require adding clap to the project, which may complicate things... Unless we want to add more environment variables (pls no). Clap would complicate things because we have to know where the cargo-mommy arguments end, and where the cargo commands begins. I suggested that we change cargo-mommy from being an extension to a simple standalone binary but Aria said no. But I think that would fix #7 and make this issue easier to fix.

@GoldsteinE
Copy link
Author

JSON could be loaded from a standard location like $XDG_CONFIG_HOME/cargo-mommy/responses.json

@catuhana
Copy link

catuhana commented Dec 24, 2022

Would require adding clap to the project, which may complicate things... Unless we want to add more environment variables (pls no). Clap would complicate things because we have to know where the cargo-mommy arguments end, and where the cargo commands begins. I suggested that we change cargo-mommy from being an extension to a simple standalone binary but Aria said no. But I think that would fix #7 and make this issue easier to fix.

Instead of CLI thingy with flags, something like confique can be used.

@catuhana
Copy link

Would require adding clap to the project, which may complicate things... Unless we want to add more environment variables (pls no). Clap would complicate things because we have to know where the cargo-mommy arguments end, and where the cargo commands begins. I suggested that we change cargo-mommy from being an extension to a simple standalone binary but Aria said no. But I think that would fix #7 and make this issue easier to fix.

Instead of CLI thingy with flags, something like confique can be used.

I implemented it on my fork, but there are some things:

  1. Default values are now in config.rs file, that's OK for pronouns and roles configuration, but Responses struct's macro is so long, and I think isn't good for maintainability. What can be done instead?
  2. Options are still String instead of Vec<String> and needs to be split with function since there's no way to set Vector (or array) with environment variables. Probably needs to be done from confique's (the runtime configuration library used) side.

And recommendations/opinions?

@VixieTSQ
Copy link
Contributor

Would require adding clap to the project, which may complicate things... Unless we want to add more environment variables (pls no). Clap would complicate things because we have to know where the cargo-mommy arguments end, and where the cargo commands begins. I suggested that we change cargo-mommy from being an extension to a simple standalone binary but Aria said no. But I think that would fix #7 and make this issue easier to fix.

Instead of CLI thingy with flags, something like confique can be used.

I implemented it on my fork, but there are some things:

1. Default values are now in `config.rs` file, that's OK for pronouns and roles configuration, but `Responses` struct's macro is so long, and I think isn't good for maintainability. What can be done instead?

2. Options are still `String` instead of `Vec<String>` and needs to be split with function since there's no way to set Vector (or array) with environment variables. Probably needs to be done from confique's (the runtime configuration library used) side.

And recommendations/opinions?

Responses really should be a path to a responses file. Just make it a pub responses: Option<Path> and bring back the include_str. Or pub responses: Option<Responses> if you really think it's that much better to have it right in the config file.

@catuhana
Copy link

Responses really should be a path to a responses file. Just make it a pub responses: Option and bring back the include_str. Or pub responses: Option if you really think it's that much better to have it right in the config file.

I created responses.toml file to include it in the compiled file for default values with include_str, but its still configurable by cargo-mommy.toml. Is this OK? If not I will split responses.toml and cargo-mommy.toml (still will bundle responses) and responses.toml will be separated.

@VixieTSQ
Copy link
Contributor

Responses really should be a path to a responses file. Just make it a pub responses: Option and bring back the include_str. Or pub responses: Option if you really think it's that much better to have it right in the config file.

I created responses.toml file to include it in the compiled file for default values with include_str, but its still configurable by cargo-mommy.toml. Is this OK? If not I will split responses.toml and cargo-mommy.toml (still will bundle responses) and responses.toml will be separated.

That's sounds good to me!

@catuhana
Copy link

Responses really should be a path to a responses file. Just make it a pub responses: Option and bring back the include_str. Or pub responses: Option if you really think it's that much better to have it right in the config file.

I created responses.toml file to include it in the compiled file for default values with include_str, but its still configurable by cargo-mommy.toml. Is this OK? If not I will split responses.toml and cargo-mommy.toml (still will bundle responses) and responses.toml will be separated.

That's sounds good to me!

Done. If it looks good I will create a pull request.
https://github.com/tuhanayim/cargo-mommy/commit/32671e6ca24fa2c4687b4a64ef64404c4045141c

@VixieTSQ
Copy link
Contributor

Responses really should be a path to a responses file. Just make it a pub responses: Option and bring back the include_str. Or pub responses: Option if you really think it's that much better to have it right in the config file.

I created responses.toml file to include it in the compiled file for default values with include_str, but its still configurable by cargo-mommy.toml. Is this OK? If not I will split responses.toml and cargo-mommy.toml (still will bundle responses) and responses.toml will be separated.

That's sounds good to me!

Done. If it looks good I will create a pull request. tuhanayim@32671e6

Go for it!

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 a pull request may close this issue.

3 participants