sigmavirus24/Todo.txt-python — Issue #18: Command-line Options Overridden by $TODO_DIR/config
Author: sigmavirus24
Created: 2012-03-06 01:08:20+00:00
State: open

# Problem Behavior

If your config file looks something like this:

```bash
export TODO_DIR="$HOME/.todo"

# etc [snip]

export PLAIN=1
```

So that ```todo.py``` prints out your todo file without colors, the following should enable colors: ```todo.py -p``` but it does not.

# Why does this happen?

We use optparse for command-line arguments. Line 1068-1072 reads as follows:

```python
valid, args = opts.parse_args()

get_config(valid.config, valid.todo_dir)
```

And we set up the ```opts``` variable mostly with callback functions. So when you run an option like this, the variable is changed, but then when the config file is read, those variables are changed to whatever is in the configuration file.

# Possible Solution(s)

I only have one right now and I'm not a fan.

## Solution 1

Keep a dictionary that the callback function manipulates and then set the ```CONFIG``` dictionary variables from this dictionary. The values in this dictionary would be a tuple like so:

```python
opt_dict = { # CONFIG_KEY : (Modified, Value),
# ...
}
```

And obviously 0 would be not modified and 1 would be modified, indicating that it was set from the command-line.