Skip to content

Commit

Permalink
Minor cleanup in template CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaro committed Dec 17, 2023
1 parent 7d73b22 commit 29b5a5b
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ class EvaluationTemplateCommand(private val cache: CacheManager) :
/**
* [CliktCommand] to create a new [DbEvaluationTemplate].
*/
inner class Create : CliktCommand(name = "create", help = "Creates a new Template") {
inner class Create : CliktCommand(
name = "create",
help = "Creates a new Template",
printHelpOnEmptyArgs = true
) {

private val name: String by option("-t", "--template", help = "Name of the new Template")
.required()
Expand All @@ -77,7 +81,11 @@ class EvaluationTemplateCommand(private val cache: CacheManager) :
/**
* [CliktCommand] to delete a [DbEvaluationTemplate].
*/
inner class Delete : CliktCommand(name = "delete", help = "Deletes a template", printHelpOnEmptyArgs = true) {
inner class Delete : CliktCommand(
name = "delete",
help = "Deletes a template",
printHelpOnEmptyArgs = true
) {

private val id: String by option("-i", "--id").required()
.validate { require(it.isNotEmpty()) { "Id must be non empty." } }
Expand All @@ -96,7 +104,11 @@ class EvaluationTemplateCommand(private val cache: CacheManager) :
/**
* [CliktCommand] to copy a [DbEvaluationTemplate].
*/
inner class Copy : CliktCommand(name = "copy", help = "Copies a Template", printHelpOnEmptyArgs = true) {
inner class Copy : CliktCommand(
name = "copy",
help = "Copies a Template",
printHelpOnEmptyArgs = true
) {

private val id: String by option("-i", "--id").required()
.validate { require(it.isNotEmpty()) { "Id must be non empty." } }
Expand All @@ -116,7 +128,11 @@ class EvaluationTemplateCommand(private val cache: CacheManager) :
/**
* [CliktCommand] to rename a [DbEvaluationTemplate].
*/
inner class Rename : CliktCommand(name = "rename", help = "Renames a Template") {
inner class Rename : CliktCommand(
name = "rename",
help = "Renames a Template",
printHelpOnEmptyArgs = true
) {

private val id: String by option("-i", "--id").required()
.validate { require(it.isNotEmpty()) { "Id must be non empty." } }
Expand Down Expand Up @@ -148,6 +164,7 @@ class EvaluationTemplateCommand(private val cache: CacheManager) :
inner class List : CliktCommand(name = "list", help = "Lists an overview of all Templates") {
override fun run() {
var no = 0
println()
println(table {
cellStyle {
border = true
Expand Down Expand Up @@ -202,7 +219,8 @@ class EvaluationTemplateCommand(private val cache: CacheManager) :
*/
inner class Prepare : CliktCommand(
name = "prepare",
help = "Checks the used media items and generates precomputed previews."
help = "Checks the used media items and generates precomputed previews.",
printHelpOnEmptyArgs = true
) {

private val id: String by option("-i", "--id").required()
Expand All @@ -224,7 +242,11 @@ class EvaluationTemplateCommand(private val cache: CacheManager) :
/**
* Exports a specific evaluation to a JSON file.
*/
inner class Export : CliktCommand(name = "export", help = "Exports a template as JSON.") {
inner class Export : CliktCommand(
name = "export",
help = "Exports a template as JSON.",
printHelpOnEmptyArgs = true
) {

/** Path to the file that should be created .*/
private val path: Path by option("-o", "--out", help = "The destination file for the template.").path()
Expand Down Expand Up @@ -266,7 +288,11 @@ class EvaluationTemplateCommand(private val cache: CacheManager) :
/**
* Imports a template from a JSON file.
*/
inner class Import : CliktCommand(name = "import", help = "Imports a template from JSON.") {
inner class Import : CliktCommand(
name = "import",
help = "Imports a template from JSON.",
printHelpOnEmptyArgs = true
) {

/** Path to the file that should be imported.*/
private val path: Path by option("-i", "--in", help = "The file to import the template from.").path().required()
Expand Down
8 changes: 6 additions & 2 deletions backend/src/main/kotlin/dev/dres/mgmt/TemplateManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -386,12 +386,16 @@ object TemplateManager {
}
}
}

println("start rendering ${segmentTasks.size} videos")

await.all {
try {
it.get(60, TimeUnit.SECONDS)
val result = it.get(3, TimeUnit.MINUTES)
println("completed rendering of $result")
true
} catch (e: Throwable) {
throw IllegalStateException("Required media file could not be prepared.")
throw IllegalStateException("Required media file could not be prepared: ${e.message}")
}
}

Expand Down

0 comments on commit 29b5a5b

Please sign in to comment.