Switch to using 'sequence'-delineated arguments given to the subprocess
run call to correctly handle whitespace.
Also check the output, so we exit if we have an error.
Test accordingly.
We regressed quiet into requiring a value to be set as a cli option
(`--quiet=true`) instead of just functioning as a flag (`--quiet`). This
change restores the previous interface on the command line,
and adds a test to ensure no regressions.
Previously, when parsing config options that were set to 'false',
e.g. `TOPEN_NOTES_QUIET=false` in the env vars,
we would still be setting it to true.
This change fixes any falsy value to be correctly parsed as False.
Turned annotation adding into a separate (pure) checking function to see
if we have to add an annotation, and a (side-effect) function which
actually adds it.
This way we can decouple checking and send an info to io only if it is
necessary while keeping the two tasks of checking and adding separate.
Since we can set the type of the relevant option in the OPTIONS dict, we
should also let the cli correctly cast them on parsing, just as the env
options do.
Main function instead returns the given error code and only when invoked
as a cli script will we use the error code to exit with the
corresponding code to the shell.
To start streamlining the TConf class a little, by removing some
internal logic which may be better residing in the Options dict,
we extract determining the correct taskrc file.
When the user exits the note-writing editor process without having
written any file, we also don't attach an annotation to the
corresponding task since it would lead nowhere.
This small change makes this condition obvious to the user, by informing
them that the program is 'doing nothing' when they exit the editor
without having saved a file.
Removed the property setters and getters from variables with complex
defaults. Instead, they are now given a specific const default value
`Path("%%%%I_DONT_EXIST_%%%%")` which is very unlikely to be used by a user
in normal circumstances.
This is necessary to be able to remove the properties since Python does
not distinguish between an empty Path() and a non-given Path() (i.e.
there is no Path value which returns Falsy).
However, this slightly clunky construct does allow setting the various
Paths once and only once, and also to remove all the previously
necessary getters and setters with their hidden backing variables.
Lastly it should open the gates for changing the _real_path
transformation to be part of the TConf class itself and not a global
function.
In the case of opening the notes but then backing out again without
actually writing a notes file we should also not annotate the task with
anything, since it technically still does not have a note.
Since the precedence now goes (from lowest to highest):
defaults -> conf_file -> env -> cli
existing EDITOR or VISUAL variables would overwrite those
explicitly set in the conf file. While we do want the general
precedence of env over conf file, this is a special case where
we get the value of the _DEFAULT_ variable from the env, and
only then start parsing our own options. So now, for these vars
we do:
default -> env (EDITOR/VISUAL) -> conf_file -> env (TOPEN_EDITOR) -> cli
In preparation for reading the config also from a taskrc file I want to
simplify the configuration management beforehand. There should be one
place where we grab it from the environment, one place to grab from CLI
and then one place from conf file. This helps with simplifying a little
by not again injecting defaults at the mid-point.
Ultimately, we should create one 'config' data structure, probably dict
or NameSpace which we pass around and each function receives it.