-
Notifications
You must be signed in to change notification settings - Fork 481
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
Add environment variable support #698
base: master
Are you sure you want to change the base?
Add environment variable support #698
Conversation
992a756
to
b954fbd
Compare
Hello? |
👋 |
🌧️ |
@ericnewton76 Could this be part of the 2.9.0 release, please? 🙂 |
🛌 |
🌤️ |
🌞 |
@ericnewton76 & @moh-hassan would be great to get this feature :) |
It looks like @moh-hassan has left this project (he's not listed in the org anymore), and @ericnewton76 has been inactive on GitHub since November. It effectively looks like this project has been abandoned, which is a shame :( |
So there is no one able to merge pullrequests to this repo? |
🌇 |
🏙️ |
🦗 |
💀 |
I created a NuGet package based on your branch: |
@jannickj , I did find one issue though. If Not sure if that is desirable. |
@devedse thx :D, also would say that is in my view expected behavior :) |
@jannickj , the thing is that this results in me having to check all variables in the code to see if they are But I'm not sure what the best solution would be. |
yeah it's a bit annoying the way to get around it is to just set it equal to [Option("host",
HelpText = "The host for the client",
Default = "localhost:80")]
public string Host { get; set; } = null!; |
That's not really what I mean. What I mean is that if you set Required = true, you need to provide the variable by passing in the flag. For example, let's assume we have:
|
right... I wasn't clear in my first message then, I tried to argue that it could make sense since required sort of strongly requests that you set the field. That said I understand what you mean and the more I think about the more I'm convinced that it's the behavior you expect. |
That's what I thought first as well. But I'm doubting it a bit now since if you look at it from the consumer end it just requires the data. It doesn't matter where it comes from. I can't think of a scenario where actually passing it as a flag is required if there is also an environment variable. But either way is fine. I'll just work with the way is implemented now. |
just read what I wrote, what I meant to say is that the behavior you (@devedse ) expected is the correct behavior, i.e. required accepts environment variables 😅 |
@jannickj , are you planning on implementing this? |
@devedse probably not, I made this PR 1.5 years ago, so at this point I'm okay with it, if someone revived this git-repo then maybe but not on a half-dead project. |
I'll see if I can make a quick fix then. I'll just release a new version of my NuGet Package |
💪 |
I think I fixed it. I actually moved all the code for setting the Value from the I also wrote some test scenario's that test I've released this version to NuGet: |
Feel free to do a code review, Incase I missed something. |
Fixes: #677
Allows for enviroment variables to be part of a cli setup the order is Args > Env > Default
NB. Currently does not support sequences (Future work - will instead crash with a helpful error msg)
I also changed 0/1 to be parsable booleans as that's the language agnotisc / most common way to set booleans via environment variables.