All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.mmauro94.mkvtoolnix_wrapper.CommandArgs.kt Maven / Gradle / Ivy

Go to download

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)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy