pimterry / notes

:pencil: Simple delightful note taking, with more unix and less lock-in.
https://github.com/pimterry/notes
MIT License
1.24k stars 82 forks source link

Added ability to override config with CLI options #63

Closed apatil closed 5 years ago

apatil commented 5 years ago

Adds ability to override config with CLI options.

I haven't added tests or updated the man page yet. I wanted to check first whether you'd be interested in this change.

Checklist

pimterry commented 5 years ago

Hmm, sorry, I'm not totally convinced by this.

I can just about see cases where you might want this, but I'm not clear why notes --editor myeditor new is better than EDITOR=myeditor notes new. The latter already works, doesn't require any separate logic, and using env vars only feels a bit simpler conceptually that having two different sources of configuration.

What do you think? Is there a reason that doesn't work?

apatil commented 5 years ago

The issue is that the config file always overrides environmental variables, and both are always read by the script. I want to put most of my notes in one folder but some notes in another folder.

primis commented 5 years ago

Since the config is a bash file itself, you could easily put a test in the config like so:

if [ -z "$EDITOR" ]
then
   EDITOR=nano
fi

This would allow an override such as @pimterry had suggested. Closing pull request as duplicate functionality.

apatil commented 5 years ago

What if I sometimes want NOTES_DIR to be /keybase/private/me/notes and sometimes /keybase/teams/someteam/notes? It's cumbersome to keep editing the config file just to put notes in another folder.

primis commented 5 years ago

In your config:

if [  -z "$NOTES_DIR" ]
then
    NOTES_DIR=<PRIMARY>
fi

And if you wanna use a different directory, run notes like: NOTES_DIR=<Directory> notes ...

apatil commented 5 years ago

Ah, I see. That works.