Skip to content

Commit d94574b

Browse files
committed
Add script documentation for kotlin-shell and kotlinx-html
1 parent 1f96764 commit d94574b

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

build.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,10 @@ allprojects {
1212
}
1313
}
1414

15+
dependencies {
16+
// adding these dependencies here just to have it locally available after gradle project import
17+
// can be useful when running performance tests for .main.kts scripts
18+
implementation("org.jetbrains.kotlinx:kotlinx-html-jvm:0.8.0")
19+
implementation("eu.jrie.jetbrains:kotlin-shell-core:0.2.1")
20+
}
21+

jvm/main-kts/scripts/kotlin-shell.main.kts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
#!/usr/bin/env kotlin
22

3+
/**
4+
* A command-line utility script that provides directory listing and word counting functionality.
5+
*
6+
* Usage:
7+
* - Without arguments: Lists files in the current directory (equivalent to `ls -l`)
8+
* - With file argument: Performs word count analysis (similar to `wc` command)
9+
* Shows both custom implementation and system `wc` command results
10+
*
11+
* Example usage:
12+
* ```
13+
* ./kotlin-shell.main.kts # Lists directory contents
14+
* ./kotlin-shell.main.kts file.txt # Counts lines, words, and characters in file.txt
15+
* ```
16+
*
17+
* Dependencies:
18+
* - kotlin-shell-core:0.2.1
19+
*
20+
* @param args - command line arguments. If provided, the first argument should be a file path
21+
*/
22+
23+
324
@file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1")
425
@file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn")
526
@file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class)

jvm/main-kts/scripts/kotlinx-html.main.kts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
#!/usr/bin/env kotlin
22

3+
/**
4+
* A demonstration script showing HTML generation using kotlinx.html DSL.
5+
* This script creates and prints a simple HTML document with a "Hello, World!" heading.
6+
*
7+
* Usage:
8+
* - Run the script to generate HTML output
9+
* - No command line arguments needed
10+
*
11+
* Dependencies:
12+
* - kotlinx-html-jvm:0.8.0
13+
*/
14+
315
@file:DependsOn("org.jetbrains.kotlinx:kotlinx-html-jvm:0.8.0")
416

517
import kotlinx.html.*
@@ -12,4 +24,3 @@ print(createHTML().html {
1224
h1 { +"Hello, $addressee!" }
1325
}
1426
})
15-

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy