So in my
pomodoro_curses C app, the code for which you can find on GitHub and which I’ve posted about in the past, I’m testing my interface as I work on how to alert the user that a time period has ended. In testing this feature, which in itself is giving me some trouble, I’m passing command-line options, because the defaults, as seen in the config file, are for long periods of time. In testing, I usually invoke it thus:
make # from the top-level project dir ./bin/pomodoro_curses -b 1 -B 1 -c config.ini -n 1 -p 2 -s 1
Read the code if you want an overview of the flags, as the exact meanings are irrelevant right now.
You can’t see
config.ini on GH, but just pretend it were
The file specifies breaks longer than a minute. When I invoke the program as above, the options set by
-[nps] all work as specified on the command line because they come after
-[bB] do not. I understand that this comes from the way that the
getopt loop works in conjunction with how I call the program.
I know that I could get around this by fiddling with the order of options on the command-line, putting
-c at the beginning to ensure that the command-line flags override the config file and then documenting that, but is there a better way to do this, in line with Exercise 28, strategy 5 (prevention over documentation, page 166)?