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

cmdlineargs: Error handling and translation #4170

Merged
merged 4 commits into from
Aug 4, 2021

Conversation

daschuer
Copy link
Member

@daschuer daschuer commented Aug 1, 2021

Added a second parser path for user feedback after the QApplication has processed the command line as well.

This allows proper feedback when a unknown command line option is found and considers also the Qt internal command line arguments.

As extra bounty the help output is now translated.

after the QApplication has processed the command line as well.

This allows proper feedback when a unknown command line option is found
and considers also the Qt internal command line arguments.

As extra bounty the help output is now translated.
@Be-ing
Copy link
Contributor

Be-ing commented Aug 1, 2021

I don't understand what "user feedback" means in this context.

@coveralls
Copy link

coveralls commented Aug 1, 2021

Pull Request Test Coverage Report for Build 1096626455

  • 28 of 42 (66.67%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 26.026%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/util/cmdlineargs.cpp 28 42 66.67%
Totals Coverage Status
Change from base Build 1087078133: 0.02%
Covered Lines: 20018
Relevant Lines: 76914

💛 - Coveralls

@daschuer
Copy link
Member Author

daschuer commented Aug 1, 2021

Main silently starts if you have a typo in the command line option.

Now it looks like this:

./mixxx --bla
QML debugging is enabled. Only use this in a safe environment.
Loading resources from  "/home/sperry/workspace/2.3/res/"
Configuration file is at version "2.3.0-beta" instead of the current "2.4.0-alpha-pre"
BroadcastSettings - Found 1 profile(s)

Unbekannte Option 'bla'.

@daschuer
Copy link
Member Author

daschuer commented Aug 1, 2021

The messages before the new line are slipping through before the logging is configured.


void CmdlineArgs::parseForUserFeedback() {
DEBUG_ASSERT(QCoreApplication::instance());
if (!m_hasUserFeedback) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition seems to be wrong or I misunderstand the purpose/naming of the boolean.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need only execute the second run when the first run has produced user feedback, otherwise we can skip the second run. I am happy to rename the variable if you have a suggestion.

Copy link
Contributor

@uklotzde uklotzde Aug 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

m_requiresUserFeedback or m_needsUserFeedback? German: "erfordert"

Copy link
Member Author

@daschuer daschuer Aug 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may be read as if we require feedback from the user.
How about m_parseForUserFeedbackRequired?


bool CmdlineArgs::parse(const QStringList& arguments, bool forUserFeedback) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add enum class ParseMode instead of using a boolean.

@daschuer
Copy link
Member Author

daschuer commented Aug 2, 2021

Done.

@daschuer
Copy link
Member Author

daschuer commented Aug 4, 2021

Done

Copy link
Contributor

@uklotzde uklotzde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Fails fast with unrecognized command line options and doesn't let them slip through silently. LGTM

@uklotzde uklotzde merged commit fa1b0fd into mixxxdj:main Aug 4, 2021
@daschuer daschuer deleted the command_line_fix_2 branch September 26, 2021 17:44
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.

None yet

4 participants