8000 GitHub - nyabkun/qq-shell-color: Kotlin library that can color your console output.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

nyabkun/qq-shell-color

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

25 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ• qq-shell-color

qq-shell-color is a Kotlin library that can color your console output.

How to use

  • Just copy and paste Single-File version QColor.kt into your project.
  • Or you can use Jar version. See Maven Dependency Section.
  • Feel free to fork or copy to your own codebase ๐Ÿ˜

Example

output

result.png

code example

Full Source : QColorExample.kt

fun colorful() {
    println("c".yellow + "o".blue + "l".red + "o".purple + "u".green + "r".cyan + "f".yellow + "u".blue + "l".red)
}

fun regex() {
    val txt = """val color = "you can use regex to color targeted text"""".qColorTarget(
        ptn = """val(?!\S)""".toRegex(),
        fg = QColor.Purple
    ).qColorTarget(
        ptn = """".*?"""".toRegex(),
        fg = QColor.Green
    )

    println(txt)
}

fun background() {
    println("background".qColor(fg = QColor.Red, bg = QColor.Blue))
}

fun decorate() {
    println("underlined".underline)
    println("italic".italic)
    println("bold".bold)
}

fun nest() {
    println("ne${"stab".blue.underline}le".yellow)
}

fun multiline() {
    val txt = """
        multiline
        multiline
    """.trimIndent().blue.underline

    println(txt)
}

Please see QColorTest.kt for more code examples. Single-File version src-test-single/QColorTest.kt is a self-contained source code that includes a runnable main function. You can easily copy and paste it into your codebase.

Public API

Single-File version Dependency

If you copy & paste QColor.kt, refer to build.gradle.kts to directly check project settings.

dependencies {
    implementation("org.jetbrains.kotlin:kotlin-stdlib:1.8.20")
    testImplementation("org.jetbrains.kotlin:kotlin-reflect:1.8.20")
}

Jar version Maven Dependency

If you prefer a jar library, you can use jitpack.io repository.

build.gradle ( Groovy )

repositories {
    ...
    maven { url 'https://jitpack.io' }
}

dependencies {
    implementation 'com.github.nyabkun:qq-shell-color:v2023-11-13-bc02'
}

build.gradle.kts ( Kotlin )

repositories {
    ...
    maven("https://jitpack.io")
}

dependencies {
    implementation("com.github.nyabkun:qq-shell-color:v2023-11-13-bc02")
}

pom.xml

<repositories>
    ...
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

<dependencies>
    ...
    <dependency>
        <groupId>com.github.nyabkun</groupId>
        <artifactId>qq-shell-color</artifactId>
        <version>v2023-11-13-bc02</version>
    </dependency>
</dependencies>

How did I create this library

  • This library was created using qq-compact-lib to generates a compact, self-contained library.
  • qq-compact-lib is a Kotlin library that can extract code elements from your codebase and make a compact library.
  • It utilizes PSI to resolve function calls and class references.
  • The original repository is currently being organized, and I'm gradually extracting and publishing smaller libraries.

References

About

Kotlin library that can color your console output.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

0