Skip to content

Commit

Permalink
feat: extended cli options
Browse files Browse the repository at this point in the history
  • Loading branch information
jenspots committed Oct 29, 2024
1 parent f843f38 commit 3412274
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
7 changes: 7 additions & 0 deletions orchestrator/rdfc-cli/src/main/kotlin/Help.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,12 @@ import kotlin.system.exitProcess
/** Prints a help message to the console and exits the process with exit code 1. */
internal fun help(): Nothing {
println("Usage: rdf-connect <mode> <path>")
println("\nModes:")
println(" install Download and prepare dependencies")
println(" exec Execute a pipeline")
println(" validate Validate a configuration file")
println("\nOptions:")
println(" -h, --help Print this help message")
println(" -v, --version Show the version number")
exitProcess(1)
}
16 changes: 13 additions & 3 deletions orchestrator/rdfc-cli/src/main/kotlin/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,27 @@ import kotlinx.coroutines.runBlocking

/** The main entry point for the RDF-Connect orchestrator. */
fun main(args: Array<String>) = runBlocking {
// No arguments provided.
if (args.isEmpty()) {
help()
}

if (args.any { it in listOf("-h", "--help") }) {
help()
}

if (args.any { it in listOf("-v", "--version") }) {
version()
}

if (args.size != 2) {
help()
}

// Execute the chosen command.
when (args[0]) {
"exec" -> exec(args[1])
"check" -> validate(args[1])
"validate" -> validate(args[1])
"install" -> install(args[1])
"help" -> help()
else -> help()
}
}
8 changes: 8 additions & 0 deletions orchestrator/rdfc-cli/src/main/kotlin/Version.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package technology.idlab.rdfc.cli

import kotlin.system.exitProcess

internal fun version(): Nothing {
println("RDF-Connect version 0.0.1")
exitProcess(0)
}

0 comments on commit 3412274

Please sign in to comment.