-
Notifications
You must be signed in to change notification settings - Fork 383
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
[#6097] improve(CLI): Add --quiet option to the Gravition CLI #6198
base: main
Are you sure you want to change the base?
Conversation
Add --quiet option to the Gravition CLI to suppress all output except for errors. [apache#6097] improve(CLI): Add --quiet option to the Gravition CLI fix test issues. [apache#6097] improve(CLI): Add --quiet option to the Gravition CLI refactor Tag, Metalake and Fileset code. [apache#6097] improve(CLI): Add --quiet option to the Gravition CLI refactor Column handler and test. [apache#6097] improve(CLI): Add --quiet option to the Gravition CLI refactor OwnerShip handler and test. [apache#6097] improve(CLI): Add --quiet option to the Gravition CLI refactor User handler and test. [apache#6097] improve(CLI): Add --quiet option to the Gravition CLI refactor Role handler and test. [apache#6097] improve(CLI): Add --quiet option to the Gravition CLI refactor Group handler and test. [apache#6097] improve(CLI): Add --quiet option to the Gravition CLI refactor Schema handler and test. [apache#6097] improve(CLI): Add --quiet option to the Gravition CLI refactor Topic handler and test. [apache#6097] improve(CLI): Add --quiet option to the Gravition CLI refactor and format handlers and test cases. [apache#6097] improve(CLI): Add --quiet option to the Gravition CLI refactor CommandHandler and TestableCommandLine. [apache#6097] improve(CLI): Add --quiet option to the Gravition CLI refactor TestableCommandLine [apache#6097] improve(CLI): Add --quiet option to the Gravition CLI refactor all commands. [apache#6097] improve(CLI): Add --quiet option to the Gravition CLI Refactor Command class . [apache#6097] improve(CLI): Add --quiet option to the Gravition CLI Add --quiet option to the Gravition CLI to suppress all output except for errors.
@justinmclean @tengqm , could you please review this PR when you have time? I’d really appreciate your feedback. |
clients/cli/src/main/java/org/apache/gravitino/cli/CatalogCommandHandler.java
Outdated
Show resolved
Hide resolved
clients/cli/src/main/java/org/apache/gravitino/cli/GravitinoOptions.java
Outdated
Show resolved
Hide resolved
clients/cli/src/test/java/org/apache/gravitino/cli/TestCatalogCommands.java
Outdated
Show resolved
Hide resolved
clients/cli/src/test/java/org/apache/gravitino/cli/TestCatalogCommands.java
Outdated
Show resolved
Hide resolved
clients/cli/src/test/java/org/apache/gravitino/cli/TestCatalogCommands.java
Outdated
Show resolved
Hide resolved
clients/cli/src/test/java/org/apache/gravitino/cli/TestCatalogCommands.java
Outdated
Show resolved
Hide resolved
clients/cli/src/test/java/org/apache/gravitino/cli/TestCatalogCommands.java
Outdated
Show resolved
Hide resolved
clients/cli/src/test/java/org/apache/gravitino/cli/TestCatalogCommands.java
Outdated
Show resolved
Hide resolved
clients/cli/src/test/java/org/apache/gravitino/cli/TestCatalogCommands.java
Outdated
Show resolved
Hide resolved
clients/cli/src/test/java/org/apache/gravitino/cli/TestCatalogCommands.java
Outdated
Show resolved
Hide resolved
clients/cli/src/test/java/org/apache/gravitino/cli/TestCatalogCommands.java
Outdated
Show resolved
Hide resolved
clients/cli/src/test/java/org/apache/gravitino/cli/TestCatalogCommands.java
Outdated
Show resolved
Hide resolved
clients/cli/src/test/java/org/apache/gravitino/cli/TestCatalogCommands.java
Outdated
Show resolved
Hide resolved
In general, this looks good, and only a couple of minor comments, but I'm not sure why you added eq calls to many tests when it's not required. |
add shortname to quiet.
Hi @justinmclean , I’ve finished updating the code. Please take a look at the PR again when you have time. |
Looks good, just one comment to address that was unresolved. |
@justinmclean fix, plz review again. |
/lgtm |
Add --quiet option to the Gravition CLI to suppress all output except for errors. [apache#6097] improve(CLI): Add --quiet option to the Gravition CLI fix test issues. [apache#6097] improve(CLI): Add --quiet option to the Gravition CLI refactor Tag, Metalake and Fileset code. [apache#6097] improve(CLI): Add --quiet option to the Gravition CLI refactor Column handler and test. [apache#6097] improve(CLI): Add --quiet option to the Gravition CLI refactor OwnerShip handler and test. [apache#6097] improve(CLI): Add --quiet option to the Gravition CLI refactor User handler and test. [apache#6097] improve(CLI): Add --quiet option to the Gravition CLI refactor Role handler and test. [apache#6097] improve(CLI): Add --quiet option to the Gravition CLI refactor Group handler and test. [apache#6097] improve(CLI): Add --quiet option to the Gravition CLI refactor Schema handler and test. [apache#6097] improve(CLI): Add --quiet option to the Gravition CLI refactor Topic handler and test. [apache#6097] improve(CLI): Add --quiet option to the Gravition CLI refactor and format handlers and test cases. [apache#6097] improve(CLI): Add --quiet option to the Gravition CLI refactor CommandHandler and TestableCommandLine. [apache#6097] improve(CLI): Add --quiet option to the Gravition CLI refactor TestableCommandLine [apache#6097] improve(CLI): Add --quiet option to the Gravition CLI refactor all commands. [apache#6097] improve(CLI): Add --quiet option to the Gravition CLI Refactor Command class . [apache#6097] improve(CLI): Add --quiet option to the Gravition CLI Add --quiet option to the Gravition CLI to suppress all output except for errors.
add shortname to quiet.
c48e92e
to
22023f3
Compare
@justinmclean @jerryshao I’ve finished updating the code. Please take a look at the PR again when you have time. |
# Conflicts: # clients/cli/src/main/java/org/apache/gravitino/cli/GravitinoCommandLine.java
…avitino into feat-quite-command
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for your work here.
What is the usage of this variable, can we elaborate the usage scenario for this? Also the change seems too fragmented, we need to change the code everywhere, A better way is to define an Besides, if we don't want output, we can simply use |
+1; the current implementation is not good. |
It was added at the request of @tengqm with the advice of https://clig.dev. For example: "For instances where you do want no output (for example, when used in shell scripts), to avoid clumsy redirection of stderr to /dev/null, you can provide a -q option to suppress all non-essential output." |
Right. This change seems like a compromise between stricter traditional command outputs and something advised elsewhere. In some reviews to CLI command outputs (cannot recall exactly which one though), I raised my concern about the necessity of printing success messages, such as "something has been successfully removed/updated". I was more inclined to explicit, ationable error messages when things go bad, or silent success with no output if an acction succeeded. We are not creating a chatbot with the CLI tool after all. Verbose outputs may also complicate the scriptability of the CLI command. There were other arguments that this verbose messages are actually desirable, and they can be suppressed using a Back to the implementation, I am a little bit sick of the actual implementation at this moment. Without an appropriate schema to group or to abstract the command line arguments, this kind of changes won't be uncommon in the foreseeable future. For example, for all A cleaner solution, on top of my head, is to have something like this:
We are not there yet. But if we are on the same page, knowing where we are heading, this change should be fine. |
I think one small improvement would be to add this to the base class:
and call optionalOutput in commands to remove the multiple Another solution to avoid passing quiet around (and changing so many files) would involve creating a global config singleton, but that has its own issues and I think is to be best avoided. We could also pass around a command context (same no of files changed, but less changes would be required for future similar changes) or as suggested above grouping different options into classes. I would suggest doing that as a separate PR for this, as the saying goes "Make it work, then make it good." |
What changes were proposed in this pull request?
Add a
--quiet
option to the Gravition CLI to suppress all output except for errors. The following command implements the logic for processing the--quiet
argument.AddXXX
CreateXXX
XXXEnable
XXXDisable
DeleteXXX
GrantXXX
RemoveXXX
RevokeXXX
SetXXXProperty
All tests have been updated. Currently, #6139, #6147, and #6152 have not been merged yet. I will update the XXXCommandHandler after they are merged.
Why are the changes needed?
Fix: #6097
Does this PR introduce any user-facing change?
No
How was this patch tested?
local test + UT