Closed Netherdrake closed 9 years ago
I broke the build, tests don't pass. However, please let me know if you're ok with the general idea.
Thank you for your contribution.
I like an idea. There are also two more ways to set configuration. Neo will by default look at file named config.toml
in the same directory as main.go
file, or you can override this by passing --config
flag to neo
CLI tool.
Just please fix the build :D, and add some tests that covers new feature.
And also can you please update configuration docs (http://ivpusic.github.io/neo/tutorials/2015/01/22/configuration.html) with the third way of setting configuration file. To update it should be really easy, just click on Improve this document
at the bottom.
Aight. I got an idea how to solve this problem in a clean fashion. WIll open a new PR when ready.
Me and my friend were hacking on neo, and we ran into an issue where setting a configuration file is really hard.
There are only 2 ways to do it in current version of neo.
1.) Injecting a fake argument into
os.Args
:The problem with this approach is that if the app is a CLI application using a framework like
codegangsta/cli
, the injection has to be done at a later time or it will breakcli
. Also its pretty non-idiomatic.2.) Manual Override:
This has an issue that the logger will complain since the neo.App() will try to set "" config file. Also, 3 lines of code is kinda ugly.
This PR allows the user to set their config like so:
Its just 1 line of code. Also, if this isn't set, it will fall-back to
--config
.If you agree with the idea, I will look into further improving the code and testing it out. I literally hacked this PR in 10min @ 4am so it might break something.