Personal terminal-like simple webpage template built with Kotlin/JS.
The template features CLI commands like help, cat, ls, grep, wc, and many more utilities. Commands support completion and piping. It's easy to implement your own commands.
# Install just (https://github.com/casey/just) for convenience
# Or use the gradle commands directly
# Development server with hot reload
just dev
# Build for production
just build
# Run all tests
just test
# Run unit tests only
just test-unit
# Run e2e tests (requires npm)
just test-e2eThe built website contains three files:
styles.cssβ terminal stylesindex.htmlβ HTML entry pointkotlin-cv.jsβ the "CLI" core, built with Kotlin/JS
# Run dev server
./gradlew jsBrowserDevelopmentRun --continuous
# Build production bundle
./gradlew jsBrowserProductionWebpack
# Run unit tests
./gradlew jsTestThe built website will be located at ./build/kotlin-webpack/js/productionExecutable/.
Deploy anywhere you want. The website can be easily deployed to GitHub Pages. The CI workflow automatically deploys to gh-pages branch on push to main.
Edit the host constant in Main.kt:
const val host = "your-domain.com"- Create a command object implementing the
Commandinterface - Add it to the registry in
Registry.kt
Example command:
object MyCommand : Command {
override val help = "description of my command"
override fun exec(argv: List<String>, print: (String) -> Unit) {
print("Hello from my command!")
}
override fun complete(argv: List<String>): List<String> {
// Return completion suggestions
return emptyList()
}
}
// In Registry.kt, add:
"mycommand" to MyCommand,Add a new File to the list in Files.kt:
val myFile = File(
"readme.txt",
"This is the content of my file.$br$br Use HTML for formatting."
)
val files = listOf(hey, quoteTxt, myFile)| Command | Description |
|---|---|
help |
Show all commands |
cat |
Display file contents |
ls |
List files (with flags: -l, -a, -h, -r, -t, -S, -1) |
tree |
Show file tree |
grep |
Search for patterns |
wc |
Word/line/char count |
head/tail |
Show first/last lines |
echo |
Print text |
clear |
Clear terminal |
history |
Show command history |
date |
Current date/time |
whoami |
Current user |
pwd |
Current directory |
printenv |
Environment variables |
uptime |
Session uptime |
neofetch |
System info |
open |
Open URL |
uuid |
Generate UUID |
base64 |
Encode/decode base64 |
json |
Pretty-print JSON |
urlencode/urldecode |
URL encoding |
color |
Preview color |
man |
Manual for command |
Commands support piping:
cat file.txt | grep pattern | wc -l
echo hello world | wc -wsrc/
βββ jsMain/
β βββ kotlin/
β β βββ commands/ # Command implementations
β β β βββ Command.kt
β β β βββ Console.kt
β β β βββ Registry.kt
β β β βββ ...
β β βββ Main.kt # Entry point
β β βββ Files.kt # Virtual filesystem
β β βββ Environment.kt
β βββ resources/
β βββ index.html
β βββ styles.css
βββ jsTest/
βββ kotlin/
βββ commands/ # Unit tests
e2e/
βββ tests/ # Playwright e2e tests
βββ playwright.config.ts
βββ package.json
