com.github.mmauro94.mkvtoolnix_wrapper.CommandArgs.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mkvtoolnix-wrapper Show documentation
Show all versions of mkvtoolnix-wrapper Show documentation
An easy to use light kotlin-jvm wrapper for most common mkvmerge and mkvpropedit CLI commands
The newest version!
package com.github.mmauro94.mkvtoolnix_wrapper
/**
* Interface that represents a class that is able to generate a single command argument
*/
interface CommandArg : CommandArgs {
/**
* @return the command arg
*/
fun commandArg(): String
/**
* Default implemented that returns a singleton list containing the single [commandArg]
*/
override fun commandArgs() = listOf(commandArg())
}
/**
* Interface that represents a class that is able to generate a list of command arguments
*/
interface CommandArgs {
/**
* @return the list of command arguments
*/
fun commandArgs(): List
}
class AdditionalArgs(
private val args: MutableList = mutableListOf()
) : MutableList by args, CommandArgs {
override fun commandArgs() = args
}
/**
* Extension function to add a [CommandArgs] to a list of strings
*/
fun MutableList.add(args: CommandArgs) {
addAll(args.commandArgs())
}
/**
* Extension function to add a vararg strings to a list
*/
fun MutableList.add(vararg args: String) {
addAll(args)
}