Commandline parsing to get basic information about the app
Implements #215
> ./build/notes --help
Usage: ./build/notes [options]
Notes is a simple note-taking application.
Options:
-h, --help Displays help on commandline options.
--help-all Displays help, including generic Qt options.
-v, --version Displays version information.
--count Count the number of notes
--trash-count Count the number of notes in the trash
--list-notes List all notes
> ./build/notes --version
Notes 2.3.1
Creating a draft PR to get initial review and more ideas on what to add to the parser.
I haven't yet implemented the count, trash-count and list-notes options, because I'm not sure how we should best handle those. It would require setting up the DBManager in main.cpp, I guess. We could also just merge without those 3 options, to at least provide a --version argument.
Closes #682
I really like this!
I can't think of any other command line switches we could add at the moment, but I like the ones you came up with.
For the --version switch ,I'd follow what most command line apps seem to output on Linux, which would be simply APP_NAME APP_VERSION (like you've showed in your post, ~~but the code seems to display it differently?~~).
I'd also add the Qt version there (build version + runtime version), similarly to what we already do in the about window, e.g.:
$ ./notes --version
Notes 2.3.1
Qt 6.8.1 (built with Qt 6.8.0)
I like showing both Qt versions because since we unfortunately rely on private Qt headers, having mismatched build/runtime versions can be a source of problems sometimes...
I think we should also change the CMakeLists file to add the git commit to the app version, only in case of a manual compile (not releases). Otherwise we won't see which commit a user built from.
That should be doable, yeah.
We actually do provide that info, but only if we build with -DGIT_REVISION=ON, which is turned off by default.
We could check if the current commit is tagged and prefixed with v, and then set GIT_REVISION=ON automatically if it's not - unless the user specifically turns it off in the command line switches.
Nice! I like where this is going. @zjeffer there are some lint errors, I believe?
Fixed the lint errors by rebasing after merging my fixes PR.
I'll look into making the APP_VERSION dynamic when I have some more time.