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

Re-order and refactor help for client/server validation #1896

Merged

Conversation

pljones
Copy link
Collaborator

@pljones pljones commented Jun 29, 2021

Short description of changes

Review and refactor command line handling in src/main.cpp to standardise how it all works.

Context: Fixes an issue?

Was part of #1867 (persistent directory lists) but really is nothing to do with it. Might unnecessarily cause conflicts in that change should src/main.cpp be amended by some other change, if left as part of it.

There's what appears to be a lot of code change - in fact, it's mostly moving existing code around. The main changes are from (new) line 533 onwards.

Does this change need documentation? What needs to be documented and how?

The code change should be self-documenting, I hope.

This change affects the --help output of Jamulus, so any documetation that references that will need reviewing. I have not looked into that aspect.

Status of this Pull Request

Working, tested code.

What is missing until this pull request can be merged?

Needs reviewing as an independent pull request. Had been reviewed under #1867 by @ann0see, I believe. See #1867 (review)

Checklist

  • I've verified that this Pull Request follows the general code principles
  • I tested my code and it does what I want
  • My code follows the style guide
  • I waited some time after this Pull Request was opened and all GitHub checks completed without errors.
  • I've filled all the content above

@ann0see
Copy link
Member

ann0see commented Jun 29, 2021

Put on my todo list for review/functionality test; but I can’t guarantee anything

@ann0see
Copy link
Member

ann0see commented Jun 30, 2021

This change affects the --help output of Jamulus, so any documetation that references that will need reviewing. I have not looked into that aspect.

I think it’s not really used anywhere yet. The CLI page was and is created manually.

Copy link
Member

@ann0see ann0see left a comment

Choose a reason for hiding this comment

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

All in all it seems to be quite OK?

Ran "./Jamulus -e" which produced the error message:
./Jamulus: '--directoryserver' needs a string argument.
This might be confusing since we passed -e not --directoryserver. Also the error message with server only options might need some thoughts and tests (In some cases I can't remember "Did you omit --server" was confusing. Maybe ./Jamulus -e -c?).

src/main.cpp Show resolved Hide resolved
src/main.cpp Show resolved Hide resolved
@pljones pljones requested review from a team, hoffie and gilgongo and removed request for a team and hoffie July 3, 2021 13:05
@pljones pljones force-pushed the refactor-jamulus-cli-handling branch from bb6709e to dbdcc4a Compare July 6, 2021 07:26
@hoffie hoffie added this to Waiting on Team in Tracking (old) Jul 7, 2021
@ann0see ann0see requested a review from softins July 11, 2021 16:31
Copy link
Member

@softins softins left a comment

Choose a reason for hiding this comment

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

Sorry for the delay - Jamulus is taking a back seat at the moment.

This PR looks ok to me. I agree with @ann0see's comment #1896 (review) regarding the error message. This could be addressed with the following diff:

diff --git a/src/main.cpp b/src/main.cpp
index 0a0a6fcb..e58d5e17 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -942,7 +942,7 @@ bool GetStringArgument ( int argc, char** argv, int& i, QString strShortOpt, QSt
     {
         if ( ++i >= argc )
         {
-            qCritical() << qUtf8Printable ( QString ( "%1: '%2' needs a string argument." ).arg ( argv[0] ).arg ( strLongOpt ) );
+            qCritical() << qUtf8Printable ( QString ( "%1: '%2' needs a string argument." ).arg ( argv[0] ).arg ( argv[i-1] ) );
             exit ( 1 );
         }

@@ -970,7 +970,7 @@ bool GetNumericArgument ( int     argc,
         QString errmsg = "%1: '%2' needs a numeric argument between '%3' and '%4'.";
         if ( ++i >= argc )
         {
-            qCritical() << qUtf8Printable ( errmsg.arg ( argv[0] ).arg ( strLongOpt ).arg ( rRangeStart ).arg ( rRangeStop ) );
+            qCritical() << qUtf8Printable ( errmsg.arg ( argv[0] ).arg ( argv[i-1] ).arg ( rRangeStart ).arg ( rRangeStop ) );
             exit ( 1 );
         }

@@ -978,7 +978,7 @@ bool GetNumericArgument ( int     argc,
         rValue = strtod ( argv[i], &p );
         if ( *p || ( rValue < rRangeStart ) || ( rValue > rRangeStop ) )
         {
-            qCritical() << qUtf8Printable ( errmsg.arg ( argv[0] ).arg ( strLongOpt ).arg ( rRangeStart ).arg ( rRangeStop ) );
+            qCritical() << qUtf8Printable ( errmsg.arg ( argv[0] ).arg ( argv[i-1] ).arg ( rRangeStart ).arg ( rRangeStop ) );
             exit ( 1 );
         }

Then the error message would mention the actual option supplied. But I don't feel strongly enough to block the PR for it.

Tracking (old) automation moved this from Waiting on Team to In Progress Jul 13, 2021
@pljones pljones force-pushed the refactor-jamulus-cli-handling branch from dbdcc4a to 733638b Compare July 15, 2021 16:18
@pljones
Copy link
Collaborator Author

pljones commented Jul 15, 2021

Patched:

peter@fs-peter:~/git/Jamulus-wip$ ./Jamulus -e
./Jamulus: '-e' needs a string argument.

And again with format fixes. Bad Tony. Bad. ;)

@pljones pljones force-pushed the refactor-jamulus-cli-handling branch from 733638b to a81f107 Compare July 15, 2021 16:25
@pljones pljones merged commit 506a33a into jamulussoftware:master Jul 16, 2021
Tracking (old) automation moved this from In Progress to Done Jul 16, 2021
@pljones pljones deleted the refactor-jamulus-cli-handling branch July 16, 2021 16:34
@ann0see ann0see added this to the Release 3.8.1 milestone Jul 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants