Load options from configuration file

14 views
Skip to first unread message

Amirouche Boubekki

unread,
Mar 11, 2012, 11:08:22 AM3/11/12
to argh-...@googlegroups.com
Héllo,

Is it possible to load startup options from a file ini ou yaml ?

Thanks in advance,

Andy Mikhailenko

unread,
Mar 11, 2012, 11:25:34 AM3/11/12
to argh-...@googlegroups.com
Hi,

> Is it possible to load startup options from a file ini ou yaml ?

I'm not sure if this is related to argh; a use case would be helpful.

Probably something like this would do:

@command
def foo(bar=None):
config = yaml.load('conf.yaml')
print(bar or config['bar'])

Of course if the app has multiple commands and each tends to load the
config, it would be a good idea to group them as class methods and
initialize the class instance with path to config, etc.

Anyway, I think configuration is out of scope of the argument parsing library.

Andy

Amirouche Boubekki

unread,
Mar 11, 2012, 1:56:31 PM3/11/12
to argh-...@googlegroups.com


On Sunday, 11 March 2012 16:25:34 UTC+1, Andy wrote:

Anyway, I think configuration is out of scope of the argument parsing library.


Me too, somewhat, I go futher in my current project and see how it goes.

Anyway some programs already use both cli arguments and config files http://gunicorn.org/configure.html#contents
Reply all
Reply to author
Forward
0 new messages