nomnom
nomnom copied to clipboard
A way to load defaults from a dotfile
I'm not sure whether this would fall under the scope of this library, but it would be super sweet to have a way to load args from a dotfile if they aren't specified in the args.
Something like this maybe:
opts = require('nomnom') .dotfile('~/.myprogram') .option('foo', {dotfileDefault: true})
would default foo to whatever was in dotfile.foo (probably the dotfile is json) ie:
$> cat ~/.myprogram {"foo": "bar"}
Or something similar, but you get the gist...
You mean like a config file?
{
"bananas": {
abbr: "b",
help: "number of bananas",
default: 3
}
}
Or just a file with defaults?
More like a file with defaults. For example, I usually have to store oauth tokens etc, rather than pass them in, it's nice to be able to just store them in a dotfile, but be able to override them as options.
I see, I see. I think for right now, loading them from file and setting the default
property would work okay, I just can't think of many other exact applications for this.