remkop / picocli

Picocli is a modern framework for building powerful, user-friendly, GraalVM-enabled command line apps with ease. It supports colors, autocompletion, subcommands, and more. In 1 source file so apps can include as source & avoid adding a dependency. Written in Java, usable from Groovy, Kotlin, Scala, etc.
https://picocli.info
Apache License 2.0
4.92k stars 423 forks source link

Feature Suggestion: Output Handler #729

Open yschimke opened 5 years ago

yschimke commented 5 years ago

Some code from my own libraries that could be useful if you want richer terminal integration.

Launching preview apps

https://github.com/yschimke/oksocial-output/blob/master/src/main/kotlin/com/baulsupp/oksocial/output/OsxOutputHandler.kt

Json pretty printing

https://github.com/yschimke/oksocial-output/blob/master/src/main/kotlin/com/baulsupp/oksocial/output/ConsoleHandler.kt

Image support (e.g. iTerm2)

https://github.com/yschimke/oksocial-output/blob/master/src/main/kotlin/com/baulsupp/oksocial/output/iterm/ItermOutputHandler.kt

yschimke commented 5 years ago

I'm mainly suggesting this as this is code I've built myself but used in multiple apps. Definitely one to close if it's not useful, but for various CLIs being able to have an API to show output to users and use the highest fidelity representation.

yschimke commented 5 years ago

Example output in iTerm

src/test/kotlin/commands/tweetsearch.kts Pusheen

image
yschimke commented 5 years ago

src/test/kotlin/commands/uberprices.kts Buckingham Palace

image
yschimke commented 5 years ago
image
remkop commented 5 years ago

All of these look very cool! I need some time to look into this in more detail. (Reminds me a bit of Windows Terminal https://github.com/microsoft/terminal/issues/448, that also opens some exciting possibilities.) Definitely interested in providing tight integration with advanced shells.

iTerm inline images: https://www.iterm2.com/documentation-images.html (also implemented by MinTTY)

Further reading: