Skip to content

[improve][cli]Support for pulsar-shell persistent modes#22522

Open
sandeep-mst wants to merge 7 commits intoapache:masterfrom
cognitree:pulsar-shell-modes-21194
Open

[improve][cli]Support for pulsar-shell persistent modes#22522
sandeep-mst wants to merge 7 commits intoapache:masterfrom
cognitree:pulsar-shell-modes-21194

Conversation

@sandeep-mst
Copy link
Copy Markdown
Contributor

Fixes 21194 of apache/pulsar

Motivation

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

Modified so that admin, client, config commands individually will launch their own mode and prompt message also gets updated. exit or quit 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

  • 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:

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

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository:
cognitree#6

@github-actions github-actions Bot added the doc-not-needed Your PR changes do not impact docs label Apr 17, 2024
Copy link
Copy Markdown
Member

@lhotari lhotari left a comment

Choose a reason for hiding this comment

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

Good work @sandeep-mst . A few minor review comments.

Comment thread pulsar-client-tools/src/main/java/org/apache/pulsar/shell/PulsarShell.java Outdated
Comment thread pulsar-client-tools/src/main/java/org/apache/pulsar/shell/PulsarShell.java Outdated
Comment thread pulsar-client-tools/src/main/java/org/apache/pulsar/shell/PulsarShell.java Outdated
Comment thread pulsar-client-tools/src/main/java/org/apache/pulsar/shell/PulsarShell.java Outdated
Comment thread pulsar-client-tools/src/main/java/org/apache/pulsar/shell/PulsarShell.java Outdated
Copy link
Copy Markdown
Contributor

@nicoloboschi nicoloboschi left a comment

Choose a reason for hiding this comment

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

I like this idea.

  1. I think we should register the new commands like other commands in registerProviders(..) so automatic autocompletion will work for these modes too.

  2. I don't understand the title, what do you mean by persistent modes ? I think we need a better name for this feature.

  3. We should add docs, at least in the help (might be mitigated by 1.)

spaces where required, single line variable, promptmessage value stays the same but the prompt varies
Comment thread pulsar-client-tools/src/main/java/org/apache/pulsar/shell/PulsarShell.java Outdated
@lhotari
Copy link
Copy Markdown
Member

lhotari commented Sep 4, 2024

I like this idea.

  1. I think we should register the new commands like other commands in registerProviders(..) so automatic autocompletion will work for these modes too.
  2. I don't understand the title, what do you mean by persistent modes ? I think we need a better name for this feature.
  3. We should add docs, at least in the help (might be mitigated by 1.)

@sandeep-mst Have you considered addressing @nicoloboschi's review feedback?
For number 2 point, calling it a "subcontext" would be perhaps better unless that concept carries already a different meaning.

For example, windows netsh has the concept of contexts and subcontexts (top level is "context", which could have "subcontexts").

@sandeep-mst
Copy link
Copy Markdown
Contributor Author

sandeep-mst commented Sep 12, 2024

I like this idea.

  1. I think we should register the new commands like other commands in registerProviders(..) so automatic autocompletion will work for these modes too.
  2. I don't understand the title, what do you mean by persistent modes ? I think we need a better name for this feature.
  3. We should add docs, at least in the help (might be mitigated by 1.)

@sandeep-mst Have you considered addressing @nicoloboschi's review feedback? For number 2 point, calling it a "subcontext" would be perhaps better unless that concept carries already a different meaning.

For example, windows netsh has the concept of contexts and subcontexts (top level is "context", which could have "subcontexts").

Hi @lhotari,

  1. I have addressed the @nicoloboschi review feedback for supporting auto-completion for shell modes for admin and client. I removed config from the provided shell modes.

I tried to implement config shell mode even though it was not requested in the issue. I was facing lot of issues with it because config is stateful and implementation might require major changes to support auto-completion.

  1. On the PR naming, context is already being used by window-functions-context of pulsar. We could still use it. Please, let me know your thoughts.
  2. I will update the PR description after confirmation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-not-needed Your PR changes do not impact docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pulsar-shell persistent modes

3 participants