nomnom icon indicating copy to clipboard operation
nomnom copied to clipboard

A way to load defaults from a dotfile

Open peterbraden opened this issue 13 years ago • 3 comments

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...

peterbraden avatar Nov 29 '11 19:11 peterbraden

You mean like a config file?

{
  "bananas": {
     abbr: "b",
     help: "number of bananas",
     default: 3
  }
}

Or just a file with defaults?

harthur avatar Dec 02 '11 20:12 harthur

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.

peterbraden avatar Dec 02 '11 20:12 peterbraden

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.

harthur avatar Dec 04 '11 05:12 harthur