You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "sandeep-mst (via GitHub)" <gi...@apache.org> on 2024/04/16 06:35:18 UTC

[PR] [improve][cli]Support for pulsar-shell persistent modes [pulsar]

sandeep-mst opened a new pull request, #22515:
URL: https://github.com/apache/pulsar/pull/22515

   <!--
   ### Contribution Checklist
     
     - PR title format should be *[type][component] summary*. For details, see *[Guideline - Pulsar PR Naming Convention](https://pulsar.apache.org/contribute/develop-semantic-title/)*. 
   
     - Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
     
     - Each pull request should address only one issue, not mix up code from multiple issues.
     
     - Each commit in the pull request has a meaningful commit message
   
     - Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
   -->
   
   <!-- Either this PR fixes an issue, -->
   
   Fixes [21194](https://github.com/apache/pulsar/issues/21194) of apache/pulsar
   
   ### Motivation
   <!-- Explain here the context, and why you're making that change. What is the problem you're trying to solve. -->
   Pulsar shell doesn't support persistent mode for admin, client, config. If we need to run a lot of admin commands for example, we would need to prefix admin each time. This will provide an alternative approach.
   
   ### Modifications
   
   <!-- Describe the modifications you've done. -->
   Modified so that `admin`, `client`, `config` commands individually will launch their own mode and prompt message also gets updated. `exitmode` command will exit from the mode to the default mode.
   In the admin mode, we can run command `topics` instead of `admin topics`.
   
   ### Verifying this change
   
   - [x] Make sure that the change passes the CI checks.
   
   *(Please pick either of the following options)*
   
   This change is already covered by existing tests, such as *(please describe tests)*.
   
   ### Does this pull request potentially affect one of the following parts:
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   *If the box was checked, please highlight the changes*
   
   - [ ] Dependencies (add or upgrade a dependency)
   - [ ] The public API
   - [ ] The schema
   - [ ] The default values of configurations
   - [ ] The threading model
   - [ ] The binary protocol
   - [ ] The REST endpoints
   - [ ] The admin CLI options
   - [ ] The metrics
   - [ ] Anything that affects deployment
   
   ### Documentation
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   - [ ] `doc` <!-- Your PR contains doc changes. -->
   - [ ] `doc-required` <!-- Your PR changes impact docs and you will update later -->
   - [x] `doc-not-needed` <!-- Your PR changes do not impact docs -->
   - [ ] `doc-complete` <!-- Docs have been already added -->
   
   ### Matching PR in forked repository
   
   PR in forked repository: <!-- ENTER URL HERE -->
   
   <!--
   After opening this PR, the build in apache/pulsar will fail and instructions will
   be provided for opening a PR in the PR author's forked repository.
   
   apache/pulsar pull requests should be first tested in your own fork since the 
   apache/pulsar CI based on GitHub Actions has constrained resources and quota.
   GitHub Actions provides separate quota for pull requests that are executed in 
   a forked repository.
   
   The tests will be run in the forked repository until all PR review comments have
   been handled, the tests pass and the PR is approved by a reviewer.
   -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [improve][cli]Support for pulsar-shell persistent modes [pulsar]

Posted by "lhotari (via GitHub)" <gi...@apache.org>.
lhotari commented on code in PR #22515:
URL: https://github.com/apache/pulsar/pull/22515#discussion_r1566813924


##########
pulsar-client-tools/src/main/java/org/apache/pulsar/shell/PulsarShell.java:
##########
@@ -567,6 +602,14 @@ private static boolean isQuitCommand(String line) {
         return line.equalsIgnoreCase("quit") || line.equalsIgnoreCase("exit");
     }
 
+    private static boolean isExitModeCommand(String line) {
+        return line.equalsIgnoreCase("exitmode");
+    }
+
+    private static boolean isChangeModeCommand(String line) {
+        return line.equalsIgnoreCase("admin") || line.equalsIgnoreCase("client") || line.equalsIgnoreCase("config");

Review Comment:
   seems like duplication. I'd assume that the ShellMode enum would have a status lookup method instead.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [improve][cli]Support for pulsar-shell persistent modes [pulsar]

Posted by "lhotari (via GitHub)" <gi...@apache.org>.
lhotari commented on code in PR #22515:
URL: https://github.com/apache/pulsar/pull/22515#discussion_r1566816835


##########
pulsar-client-tools/src/main/java/org/apache/pulsar/shell/PulsarShell.java:
##########
@@ -567,6 +602,14 @@ private static boolean isQuitCommand(String line) {
         return line.equalsIgnoreCase("quit") || line.equalsIgnoreCase("exit");
     }
 
+    private static boolean isExitModeCommand(String line) {
+        return line.equalsIgnoreCase("exitmode");
+    }
+
+    private static boolean isChangeModeCommand(String line) {
+        return line.equalsIgnoreCase("admin") || line.equalsIgnoreCase("client") || line.equalsIgnoreCase("config");

Review Comment:
   for example https://www.baeldung.com/java-enum-values contains some advice how this could be handled.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [improve][cli]Support for pulsar-shell persistent modes [pulsar]

Posted by "sandeep-mst (via GitHub)" <gi...@apache.org>.
sandeep-mst commented on PR #22515:
URL: https://github.com/apache/pulsar/pull/22515#issuecomment-2060792240

   Closing in favour of https://github.com/apache/pulsar/pull/22522
   I have resolved the review comments in that PR


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [improve][cli]Support for pulsar-shell persistent modes [pulsar]

Posted by "lhotari (via GitHub)" <gi...@apache.org>.
lhotari commented on code in PR #22515:
URL: https://github.com/apache/pulsar/pull/22515#discussion_r1566809132


##########
pulsar-client-tools/src/main/java/org/apache/pulsar/shell/PulsarShell.java:
##########
@@ -567,6 +602,14 @@ private static boolean isQuitCommand(String line) {
         return line.equalsIgnoreCase("quit") || line.equalsIgnoreCase("exit");
     }
 
+    private static boolean isExitModeCommand(String line) {
+        return line.equalsIgnoreCase("exitmode");
+    }

Review Comment:
   there shouldn't be a separate `exitmode` command. Simple `exit` or pressing CTRL-D should do that. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [improve][cli]Support for pulsar-shell persistent modes [pulsar]

Posted by "lhotari (via GitHub)" <gi...@apache.org>.
lhotari commented on PR #22515:
URL: https://github.com/apache/pulsar/pull/22515#issuecomment-2058366744

   @sandeep-mst Thanks for the contribution. Please target the `master` branch since we currently follow that type of process where PRs target the master branch when it's applicable.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [improve][cli]Support for pulsar-shell persistent modes [pulsar]

Posted by "sandeep-mst (via GitHub)" <gi...@apache.org>.
sandeep-mst closed pull request #22515: [improve][cli]Support for pulsar-shell persistent modes
URL: https://github.com/apache/pulsar/pull/22515


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org