-
Notifications
You must be signed in to change notification settings - Fork 421
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
Allow users of picocli-shell-jline3 to use clear
command and a nicer help
command
#1265
Conversation
clear
command and a nicer `help commandclear
command and a nicer help
command
@remkop - any thoughts on this? |
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.
@sualeh I finally had time to look at this in more detail.
I have an idea for keeping things more declarative, can you take a look and let me know your thoughts?
picocli-shell-jline3/src/main/java/picocli/shell/jline3/PicocliCommands.java
Outdated
Show resolved
Hide resolved
picocli-shell-jline3/src/main/java/picocli/shell/jline3/PicocliCommands.java
Outdated
Show resolved
Hide resolved
picocli-shell-jline3/src/main/java/picocli/shell/jline3/PicocliCommands.java
Show resolved
Hide resolved
picocli-shell-jline3/src/test/java/picocli/shell/jline3/example/Example.java
Show resolved
Hide resolved
picocli-shell-jline3/src/main/java/picocli/shell/jline3/PicocliCommands.java
Outdated
Show resolved
Hide resolved
picocli-shell-jline3/src/test/java/picocli/shell/jline3/example/Example.java
Outdated
Show resolved
Hide resolved
Codecov Report
@@ Coverage Diff @@
## master #1265 +/- ##
=========================================
Coverage 93.82% 93.82%
Complexity 462 462
=========================================
Files 2 2
Lines 6852 6852
Branches 1842 1842
=========================================
Hits 6429 6429
Misses 138 138
Partials 285 285 Continue to review full report at Codecov.
|
@remkop - thanks for the last snippet. I think I have finally understood (sorry for being dense), and pushed what I think are the final changes. Please take a look. Thanks. |
Great! Let me check when I get to my PC. |
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.
Thank you for the changes, @sualeh, this looks pretty good now!
For finishing touches, can you add some javadoc?
Also I believe the factory and the clear-screen subcommand should require a LineReaderImpl
; this is not great, but we cannot call clearScreen
on any LineReader
. This is also something we should probably raise with the JLine maintainers: they should consider adding the clearScreen
method to the LineReader
interface.
picocli-shell-jline3/src/main/java/picocli/shell/jline3/PicocliCommands.java
Show resolved
Hide resolved
picocli-shell-jline3/src/main/java/picocli/shell/jline3/PicocliCommands.java
Outdated
Show resolved
Hide resolved
picocli-shell-jline3/src/main/java/picocli/shell/jline3/PicocliCommands.java
Show resolved
Hide resolved
picocli-shell-jline3/src/main/java/picocli/shell/jline3/PicocliCommands.java
Outdated
Show resolved
Hide resolved
picocli-shell-jline3/src/test/java/picocli/shell/jline3/example/Example.java
Outdated
Show resolved
Hide resolved
picocli-shell-jline3/src/main/java/picocli/shell/jline3/PicocliCommands.java
Show resolved
Hide resolved
2. Use LineReaderImpl instead of LineReader, and have the client/ caller do the cast 3. Add a constructor to allow factories to be chained
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.
@remkop - I have made the clean-up changes you suggested.
- I want to remove
workDir
fromPicocliCommands
. Please let me know if you need a separate pull request for that, or if I can include it in the same PR. - I will test the suggestion in Expose
clearScreen
onLineReader
jline/jline3#610 and see if that works - then we can go back to usingLineReader
picocli-shell-jline3/src/test/java/picocli/shell/jline3/example/Example.java
Outdated
Show resolved
Hide resolved
picocli-shell-jline3/src/test/java/picocli/shell/jline3/example/Example.java
Outdated
Show resolved
Hide resolved
I'm fine with removing workDir (thanks! :-)), no need for a separate pull request. Happy to use the LineReader interface if possible, let me know how it goes. |
@remkop - I think we are done. I have removed |
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.
This looks good, thank you!
I will merge this soon.
This will be included in the upcoming picocli 4.6 release.
Thank you again for the contribution!
…eReaderImpl, as suggested in jline/jline3#610
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.
Ah very nice!
Using a public API like Terminal is a lot nicer than having to use internal API like LineReaderImpl.
Thanks for following up!
Merged. |
…ancement" This reverts commit 0f160bf.
…ent" This reverts commit 5a17396.
…ancement" This reverts commit 0f160bf.
…ent" This reverts commit 5a17396.
Allow users of picocli-shell-jline3 to use
clear
command and a nicerhelp
command.picocli.shell.jline3.PicocliCommands
. This change allows users ofPicocliCommands
to include a clear screen command with a single line:picocliCommands.includeClearScreenCommand(reader);
- see the example.PicocliCommands
to override the jline3 help command with a single line:systemRegistry.register("help", picocliCommands);
- see the example.