Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 39 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ Validate a single UUID or ULID value using the `validate` subcommand.
jack uuid validate <uuid>
echo "3fa85f64-5717-4562-b3fc-2c963f66afa6" | jack uuid validate
jack uuid validate --type ULID <ulid>
jack uuid validate --quiet --verbose <uuid>
```

### Lorem Ipsum
Expand All @@ -93,10 +94,12 @@ jack hash --file path/to/file.txt --algorithm MD5
```

### Timestamps
Get the current Unix timestamp.
Get the current Unix timestamp, or parse/format values.
```bash
jack timestamp
jack timestamp --unit MILLISECONDS
jack timestamp 2023-01-01
jack timestamp 1672531200 --unit SECONDS --format ISO
```

### JWT Decoding
Expand Down Expand Up @@ -130,8 +133,39 @@ jack json --compact '{"name": "jack", "version": 1}'
jack json -c -q ".data" '{"data":{"a":1,"b":2}}'
```

### Base64
Encode or decode text to/from Base64.
```bash
jack base64 encode "hello world"
jack base64 decode "aGVsbG8gd29ybGQ="
```

### Networking
Quick network utilities.
```bash
jack net ip
jack net dns google.com
```

### Cron
Work with cron expressions.
```bash
jack cron explain "*/5 * * * *"
jack cron next "0 12 * * *"
```

### Maintenance
Manage `jack` itself.
```bash
jack upgrade
jack autocomplete
```

### Shell Completion

Enable tab completion for jack commands in your shell.

**Linux / macOS:**
```bash
jack completion
```
Expand All @@ -158,9 +192,12 @@ _JACK_COMPLETE=fish jack > ~/.config/fish/completions/jack.fish
- **Lorem Ipsum**: Customizable placeholder text.
- **QR Codes**: PNG generation with custom colors.
- **Hashing**: MD5, SHA1, SHA256, SHA512 support.
- **Timestamps**: Seconds or milliseconds.
- **Timestamps**: Seconds or milliseconds, parsing and formatting.
- **JWT Decoding**: Pretty print header and payload with signature verification.
- **JSON Processing**: Query, format, and minify JSON with dot-notation queries.
- **Base64**: Encoding and decoding utilities.
- **Networking**: IP lookup and DNS resolution.
- **Cron**: Human readable descriptions and next execution calculation.

## License
MIT
Expand Down
69 changes: 0 additions & 69 deletions build.gradle

This file was deleted.

79 changes: 79 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
plugins {
kotlin("jvm") version "2.1.20"
kotlin("plugin.serialization") version "2.1.20"
application
id("com.diffplug.spotless") version "7.0.0.BETA4"
id("org.graalvm.buildtools.native") version "0.10.4"
}

group = "org.jack"
version = project.properties["version"] as String

repositories {
mavenCentral()
}

dependencies {
testImplementation(kotlin("test"))
testImplementation("io.mockk:mockk:1.13.13")

implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0")
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.2")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0")
implementation("com.github.ajalt.clikt:clikt:5.0.3")
implementation("com.github.ajalt.clikt:clikt-markdown:5.0.3")
implementation("io.github.g0dkar:qrcode-kotlin:4.4.1")
implementation("com.aallam.ulid:ulid-kotlin:1.3.0")
implementation("com.cronutils:cron-utils:9.2.1")
}

tasks.test {
useJUnitPlatform()
}

configurations {
compileClasspath {
resolutionStrategy.activateDependencyLocking()
}
}

kotlin {
jvmToolchain(21)
}

dependencyLocking {
lockAllConfigurations()
}

application {
mainClass.set("org.jack.MainKt")
}

graalvmNative {
binaries {
named("main") {
imageName.set("jack")
mainClass.set("org.jack.MainKt")
fallback.set(false)
buildArgs.add("--enable-url-protocols=https")
}
}
toolchainDetection.set(true)
}

spotless {
kotlin {
target("src/**/*.kt")
ktlint()
}
kotlinGradle {
target("*.gradle.kts")
ktlint()
}
}

tasks.processResources {
filesMatching("version.properties") {
expand(project.properties)
}
}
22 changes: 18 additions & 4 deletions gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# This file is expected to be part of source control.
com.aallam.ulid:ulid-kotlin-jvm:1.3.0=compileClasspath,nativeImageClasspath,nativeImageTestClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.aallam.ulid:ulid-kotlin:1.3.0=compileClasspath,implementationDependenciesMetadata,nativeImageClasspath,nativeImageTestClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
com.cronutils:cron-utils:9.2.1=compileClasspath,implementationDependenciesMetadata,nativeImageClasspath,nativeImageTestClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
com.github.ajalt.clikt:clikt-core-jvm:5.0.3=compileClasspath,nativeImageClasspath,nativeImageTestClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.github.ajalt.clikt:clikt-core:5.0.3=compileClasspath,implementationDependenciesMetadata,nativeImageClasspath,nativeImageTestClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
com.github.ajalt.clikt:clikt-jvm:5.0.3=compileClasspath,nativeImageClasspath,nativeImageTestClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
Expand All @@ -25,11 +26,23 @@ com.github.ajalt.mordant:mordant-markdown:3.0.1=compileClasspath,implementationD
com.github.ajalt.mordant:mordant:3.0.1=compileClasspath,implementationDependenciesMetadata,nativeImageClasspath,nativeImageTestClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
io.github.g0dkar:qrcode-kotlin-jvm:4.4.1=compileClasspath,nativeImageClasspath,nativeImageTestClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
io.github.g0dkar:qrcode-kotlin:4.4.1=compileClasspath,implementationDependenciesMetadata,nativeImageClasspath,nativeImageTestClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
net.bytebuddy:byte-buddy-agent:1.17.5=nativeImageTestClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
net.bytebuddy:byte-buddy:1.17.5=nativeImageTestClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
io.mockk:mockk-agent-api-jvm:1.13.13=nativeImageTestClasspath,testCompileClasspath,testRuntimeClasspath
io.mockk:mockk-agent-api:1.13.13=nativeImageTestClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
io.mockk:mockk-agent-jvm:1.13.13=nativeImageTestClasspath,testCompileClasspath,testRuntimeClasspath
io.mockk:mockk-agent:1.13.13=nativeImageTestClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
io.mockk:mockk-core-jvm:1.13.13=nativeImageTestClasspath,testCompileClasspath,testRuntimeClasspath
io.mockk:mockk-core:1.13.13=nativeImageTestClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
io.mockk:mockk-dsl-jvm:1.13.13=nativeImageTestClasspath,testCompileClasspath,testRuntimeClasspath
io.mockk:mockk-dsl:1.13.13=nativeImageTestClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
io.mockk:mockk-jvm:1.13.13=nativeImageTestClasspath,testCompileClasspath,testRuntimeClasspath
io.mockk:mockk:1.13.13=nativeImageTestClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
junit:junit:4.13.2=nativeImageTestClasspath,testRuntimeClasspath
net.bytebuddy:byte-buddy-agent:1.14.17=nativeImageTestClasspath,testCompileClasspath,testRuntimeClasspath
net.bytebuddy:byte-buddy:1.14.17=nativeImageTestClasspath,testCompileClasspath,testRuntimeClasspath
net.java.dev.jna:jna:5.14.0=nativeImageClasspath,nativeImageTestClasspath,runtimeClasspath,testRuntimeClasspath
org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath
org.graalvm.buildtools:junit-platform-native:0.10.4=nativeImageTestClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.hamcrest:hamcrest-core:1.3=nativeImageTestClasspath,testRuntimeClasspath
org.jetbrains.intellij.deps:trove4j:1.0.20200330=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-build-tools-api:2.1.20=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-build-tools-impl:2.1.20=kotlinBuildToolsApiClasspath
Expand All @@ -39,6 +52,7 @@ org.jetbrains.kotlin:kotlin-daemon-client:2.1.20=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-daemon-embeddable:2.1.20=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-klib-commonizer-embeddable:2.1.20=kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-reflect:1.6.10=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-reflect:2.0.0=nativeImageTestClasspath,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-script-runtime:2.1.20=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-scripting-common:2.1.20=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:2.1.20=kotlinBuildToolsApiClasspath,kotlinCompilerPluginClasspathMain,kotlinCompilerPluginClasspathTest
Expand Down Expand Up @@ -77,7 +91,7 @@ org.junit.platform:junit-platform-engine:1.10.1=nativeImageTestClasspath,testRun
org.junit.platform:junit-platform-launcher:1.10.1=nativeImageTestClasspath,testRuntimeClasspath
org.junit.platform:junit-platform-reporting:1.10.1=nativeImageTestClasspath,testRuntimeClasspath
org.junit:junit-bom:5.10.1=nativeImageTestClasspath,testCompileClasspath,testRuntimeClasspath
org.mockito:mockito-core:5.18.0=nativeImageTestClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.objenesis:objenesis:3.3=nativeImageTestClasspath,testRuntimeClasspath
org.objenesis:objenesis:3.3=nativeImageTestClasspath,testCompileClasspath,testRuntimeClasspath
org.opentest4j:opentest4j:1.3.0=nativeImageTestClasspath,testCompileClasspath,testRuntimeClasspath
org.slf4j:slf4j-api:2.0.7=compileClasspath,implementationDependenciesMetadata,nativeImageClasspath,nativeImageTestClasspath,runtimeClasspath,testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
empty=annotationProcessor,compileOnlyDependenciesMetadata,intransitiveDependenciesMetadata,kotlinCompilerPluginClasspath,kotlinNativeCompilerPluginClasspath,kotlinScriptDefExtensions,testAnnotationProcessor,testApiDependenciesMetadata,testCompileOnlyDependenciesMetadata,testIntransitiveDependenciesMetadata,testKotlinScriptDefExtensions
10 changes: 0 additions & 10 deletions spotless.gradle

This file was deleted.

65 changes: 38 additions & 27 deletions src/main/kotlin/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,58 @@ package org.jack

import com.github.ajalt.clikt.core.main
import com.github.ajalt.clikt.core.subcommands
import org.jack.di.AppModule
import org.jack.features.autocomplete.AutocompleteCommand
import org.jack.features.base64.Base64Command
import org.jack.features.base64.subcommands.DecodeCommand
import org.jack.features.base64.subcommands.EncodeCommand
import org.jack.features.cron.CronCommand
import org.jack.features.cron.subcommands.ExplainCommand
import org.jack.features.cron.subcommands.NextCommand
import org.jack.features.hash.HashCommand
import org.jack.features.hash.services.impl.HashServiceImpl
import org.jack.features.jack.JackCommand
import org.jack.features.json.JsonCommand
import org.jack.features.json.services.impl.JsonServiceImpl
import org.jack.features.jwt.JwtCommand
import org.jack.features.jwt.services.impl.JwtServiceImpl
import org.jack.features.lorem.LoremCommand
import org.jack.features.lorem.services.impl.LoremIpsumServiceImpl
import org.jack.features.net.NetCommand
import org.jack.features.net.subcommands.DnsCommand
import org.jack.features.net.subcommands.IpCommand
import org.jack.features.qr.QrCommand
import org.jack.features.qr.services.impl.QrCodeWriterServiceImpl
import org.jack.features.timestamp.TimestampCommand
import org.jack.features.timestamp.services.impl.TimestampServiceImpl
import org.jack.features.upgrade.UpgradeCommand
import org.jack.features.upgrade.services.impl.UpgradeServiceImpl
import org.jack.features.uuid.UuidCommand
import org.jack.features.uuid.services.impl.UuidServiceImpl
import org.jack.features.uuid.subcommands.GenerateCommand
import org.jack.features.uuid.subcommands.ValidateCommand
import org.jack.features.uuid.subcommands.GenerateCommand as UuidGenerateCommand

fun main(args: Array<String>) {
val uuidService = UuidServiceImpl()
val loremIpsumService = LoremIpsumServiceImpl()
val qrCodeWriterService = QrCodeWriterServiceImpl()
val timestampService = TimestampServiceImpl()
val hashService = HashServiceImpl()
val jwtService = JwtServiceImpl()
val jsonService = JsonServiceImpl()
val upgradeService = UpgradeServiceImpl()

val uuidCommand =
UuidCommand().subcommands(
GenerateCommand(uuidService),
ValidateCommand(uuidService),
UuidGenerateCommand(AppModule.uuidService),
ValidateCommand(AppModule.uuidService),
)

val loremCommand = LoremCommand(loremIpsumService)
val qrCommand = QrCommand(qrCodeWriterService)
val timestampCommand = TimestampCommand(timestampService)
val hashCommand = HashCommand(hashService)
val jwtCommand = JwtCommand(jwtService)
val jsonCommand = JsonCommand(jsonService)
val upgradeCommand = UpgradeCommand(upgradeService)
val loremCommand = LoremCommand(AppModule.loremIpsumService)
val qrCommand = QrCommand(AppModule.qrCodeWriterService)
val timestampCommand = TimestampCommand(AppModule.timestampService)
val hashCommand = HashCommand(AppModule.hashService)
val jwtCommand = JwtCommand(AppModule.jwtService)
val jsonCommand = JsonCommand(AppModule.jsonService)
val upgradeCommand = UpgradeCommand(AppModule.upgradeService)
val netCommand =
NetCommand(AppModule.netService).subcommands(
IpCommand(AppModule.netService),
DnsCommand(AppModule.netService),
)
val base64Command =
Base64Command(AppModule.base64Service).subcommands(
EncodeCommand(AppModule.base64Service),
DecodeCommand(AppModule.base64Service),
)
val cronCommand =
CronCommand().subcommands(
ExplainCommand(AppModule.cronService),
NextCommand(AppModule.cronService),
)
val completionCommand = AutocompleteCommand()

val jackCommand =
Expand All @@ -59,6 +67,9 @@ fun main(args: Array<String>) {
jwtCommand,
jsonCommand,
upgradeCommand,
netCommand,
base64Command,
cronCommand,
completionCommand,
)

Expand Down
Loading
Loading