Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commandline parsing to get basic information about the app #734

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zjeffer
Copy link
Collaborator

@zjeffer zjeffer commented Jan 20, 2025

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.

@zjeffer zjeffer requested review from guihkx and nuttyartist January 20, 2025 22:39
@guihkx
Copy link
Collaborator

guihkx commented Jan 21, 2025

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...

@zjeffer
Copy link
Collaborator Author

zjeffer commented Jan 21, 2025

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.

@guihkx
Copy link
Collaborator

guihkx commented Jan 21, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants