8000 Give Suggestions to User if they Enter an Incorrect Command by fhembroff · Pull Request #221 · dockstore/dockstore-cli · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Give Suggestions to User if they Enter an Incorrect Command #221

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

Conversation

fhembroff
Copy link
Contributor
@fhembroff fhembroff commented Feb 2, 2023

Description
This PR implements a suggestion tool in a few parts of the CLI. It will provide the user the most similar command to the incorrect command they entered. For example,

> java -jar dockstore-client/target/dockstore-client-1.14.0-SNAPSHOT-shaded.jar checkers
dockstore: 'checkers' is not a dockstore command. See 'dockstore --help'.

The most similar command is:
    checker

> java -jar dockstore-client/target/dockstore-client-1.14.0-SNAPSHOT-shaded.jar workflow wes lunch
dockstore workflow wes: 'lunch' is not a dockstore command. See 'dockstore workflow wes --help'.

The most similar command is:
    launch

Whilst implementing this, I also created a lot of constants for strings that were commonly used in the CLI (for example, "launch", "workflow" and "--entry"). This is why this PR effects so many files. To make this PR (hopefully) easier to review I have commented on the important files.

I have implemented this functionality for the following types of commands:

dockstore INVALID_COMMAND
dockstore workflow INVALID_COMMAND
dockstore tool INVALID_COMMAND
dockstore tool convert INVALID_COMMAND
dockstore workflow convert INVALID_COMMAND
dockstore workflow wes INVALID_COMMAND (and all sub-commands for WES)
dockstore plugin INVALID_COMMAND
dockstore deps INVALID_COMMAND

The following only have 1 flag that is required (generally --entry) and the user is told if the flag isn't provided, I haven't included the suggestion functionality on these.

dockstore tool search
dockstore tool star
dockstore tool test_parameter
dockstore workflow CWL
dockstore workflow search
dockstore workflow star
dockstore workflow test_parameter
dockstore workflow NFL
dockstore workflow restub
dockstore checker download

Quite a few commands switch statements to process entry commands. After talking with @denis-yuen , it was decided that it would be better leave them as is and create this ticket dockstore/dockstore#5344 to setup the suggestion system after JCommander had been added to them.

Review Instructions

  • Ensure that none of the help pages were messed up due to the variable substitutions (i.e. a space being removed). This isn't really tested in any of our tests.
  • Ensure that helpful suggestions are given to the users in all areas where this functionality was implemented.

Issue
DOCK-2172
dockstore/dockstore#4910

Security
If there are any concerns that require extra attention from the security team, highlight them here.

Please make sure that you've checked the following before submitting your pull request. Thanks!

  • Check that you pass the basic style checks and unit tests by running ./mvnw clean install
  • If this PR is for a user-facing feature, create and link a documentation ticket for this feature (usually in the same milestone as the linked issue). Style points if you create a documentation PR directly and link that instead.

The threshold could change, but noSolutionsShouldBeDisplayed tests should always result in no strings being returned
out(MessageFormat.format("\tdockstore workflow wes logs --id {0}", runId));
out("To view the workflow run " + STATUS + ", execute: ");
out(MessageFormat.format("\tdockstore workflow {0} {1} {2} {3}", WES, STATUS, ID, runId));
out(MessageFormat.format("\tdockstore workflow {0} {1} {2} {3}", WES, LOGS, ID, runId));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I couldn't find any documentation for the {#} notation, only examples of it being used. Just wanted to double check I used this correctly.

@fhembroff fhembroff requested a review from denis-yuen February 6, 2023 16:09
@fhembroff
Copy link
Contributor Author

It appears that all the tests are failing right now due to the rate limit.

@denis-yuen
Copy link
Member

It appears that all the tests are failing right now due to the rate limit.

Hmmm, you may need to space out your pushes or group more commits together (since a build starts when you push).
Sometimes the messages for the rate limit show up in the build, for example

io.swagger.client.ApiException: Out of GitHub rate limit, please wait til 2023-02-06T16:21:41Z[Etc/UTC]
https://app.circleci.com/pipelines/github/dockstore/dockstore-cli/1431/workflows/0c395c62-6fa8-4d4e-9655-d6898b64bd24/jobs/6537

@denis-yuen
Copy link
Member

Alternatively, I'm experimenting with a webservice update dockstore/dockstore#5346

Copy link
Member
@denis-yuen denis-yuen left a comment

Choose a reason for hiding this comment

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

With a passing build

…display-help-message-if-invalid-parameter-is-entered

# Conflicts:
#	dockstore-cli-integration-testing/src/test/java/io/dockstore/client/cli/GeneralWorkflowIT.java
#	dockstore-cli-integration-testing/src/test/java/io/dockstore/client/cli/QuayGitHubBasicIT.java
@codecov
Copy link
codecov bot commented Feb 7, 2023

Codecov Report

Base: 68.97% // Head: 69.42% // Increases project coverage by +0.44% 🎉

Coverage data is based on head (091aff0) compared to base (44080ec).
Patch coverage: 74.56% of modified lines in pull request are covered.

Additional details and impacted files
@@              Coverage Diff              @@
##             develop     #221      +/-   ##
=============================================
+ Coverage      68.97%   69.42%   +0.44%     
- Complexity      1012     1034      +22     
=============================================
  Files             47       47              
  Lines           5937     6034      +97     
  Branches         776      789      +13     
=============================================
+ Hits            4095     4189      +94     
- Misses          1509     1510       +1     
- Partials         333      335       +2     
Flag Coverage Δ
bitbuckettests 9.89% <3.04%> (-0.17%) ⬇️
confidentialtooltests 54.59% <64.34%> (+1.11%) ⬆️
confidentialworkflowtests 27.72% <7.39%> (-0.42%) ⬇️
nonconfidentialtests 32.41% <16.08%> (-0.48%) ⬇️
singularitytests 16.70% <1.52%> (-0.28%) ⬇️
unittests 8.36% <8.47%> (+0.38%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ain/java/io/dockstore/client/cli/SearchClient.java 0.00% <0.00%> (ø)
.../main/java/io/dockstore/client/cli/YamlClient.java 82.85% <0.00%> (ø)
...ockstore/client/cli/nested/BaseLanguageClient.java 57.83% <0.00%> (ø)
...va/io/dockstore/client/cli/nested/WesLauncher.java 46.72% <0.00%> (ø)
...io/dockstore/client/cli/nested/WesRequestData.java 56.36% <ø> (ø)
...in/java/io/dockstore/common/FileProvisionUtil.java 72.03% <0.00%> (ø)
.../io/dockstore/common/ToolWorkflowDeserializer.java 0.00% <0.00%> (ø)
...ithub/collaboratory/cwl/cwlrunner/ToilWrapper.java 0.00% <0.00%> (ø)
...ain/java/io/dockstore/client/cli/PluginClient.java 76.66% <50.00%> (-4.82%) ⬇️
...ava/io/dockstore/client/cli/nested/DepCommand.java 58.06% <50.00%> (-1.94%) ⬇️
... and 22 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Removed public modifier
Removed unneeded continue statement
Changed ArrayList<String> to ArrayList<>
Changed ArrayList<String> to ArrayList<>
Put two cases on the same line
Changed <String> to <>
Changed <String> to <>
Changed <String> to <>
Removed unneeded .toString()
Changed System.out.println out
<String> to <>
Removed unneeded .toString()
Added constant
<String> -> <>
<String> -> <>
Removed unneeded public
Removed unneeded public
@sonarqubecloud
Copy link
sonarqubecloud bot commented Feb 7, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 41 Code Smells

77.6% 77.6% Coverage
0.4% 0.4% Duplication

@fhembroff
Copy link
Contributor Author

We have a passing build!

I have corrected about 20 of the sonar cloud issues.

@fhembroff fhembroff merged commit 8abe8c6 into develop Feb 8, 2023
@fhembroff fhembroff deleted the feature/DOCK-2172/display-help-message-if-invalid-parameter-is-entered branch February 8, 2023 14:19
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.

5 participants
0