CmdBuilder

class CmdBuilder(val cmdLang: CmdLang, val outputHandler: CmdOutputHandler) : CmdLang

Builder that constructs and specifies commands for a pipeline stage to execute, packaged convenient methods for common tasks like reporting command results.

Constructors

Link copied to clipboard
constructor(cmdLang: CmdLang, outputHandler: CmdOutputHandler)

Types

Link copied to clipboard
sealed class Cmd(val cmd: String)

Represents a wrapped type around a string command with variants to handle optional interaction with a Var.

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
val cmd: String

Resultant command specification for the entire builder. A property for getting a view of the current set of commands in this CmdBuilder.

Link copied to clipboard
private val cmdLang: CmdLang

the language that commands are written in.

Link copied to clipboard

Internal representation of the core commands: commands that are the main intented action in the stage and are not solely for supporting outputting.

Link copied to clipboard

Simplified and more readable command specification for the entire builder, omitting all capturing of useful variable results. A property for getting a view of the current set of literal commands in this CmdBuilder.

Link copied to clipboard
open override val DEFAULT_EXITCODE: Int

Default exitcode of a variable if stage execution timed out.

Link copied to clipboard
private var exiting: CmdBuilder.Cmd?

Internal representation of the exit command of the stage. If it is null, no exiting command will be issued by the builder for the user.

Link copied to clipboard
open override val hereDoc: CmdLang.HereDoc

Heredoc with certain delimiters under this CmdLang.

Link copied to clipboard
Link copied to clipboard

handler of command outputs under cmdLang.

Functions

Link copied to clipboard
fun add(v: CmdUtils.Var? = null, cmd: () -> String): CmdBuilder

Primary action that appends a command to the CmdBuilder.

Link copied to clipboard
open override fun catFile(path: String): String

Read-out file into stdout

Link copied to clipboard
open override fun deref(variable: String): String

Interpret the variable if it is defined the command line environment by dereferencing.

Link copied to clipboard
open override fun exitCmd(exitcode: String): String

Command for exiting with a given exitcode integer or expression.

Link copied to clipboard

Action that makes the entire command exit according to exit code of a used Var.

fun exitWith(exitCode: Int): CmdBuilder

Action that makes the entire command exit according to exitCode.

Link copied to clipboard
open override fun expand(cmd: String): String

Expand and interpret the command expression in the shell, so that it can be used to construct further commands by substituting.

Link copied to clipboard
open override fun <T> from(result: CmdUtils.Var.Result<T>): String

Command building combinators to pipe contents from previously saved Var.baseName's stdout/stderr.

Link copied to clipboard

Action that enables the logging of expanded full commands instead of just the core command fragments.

Link copied to clipboard
open override fun makeHeredoc(content: String): String

Command building combinator to make heredocs normally. Usually to be registed into a Var or piped into other commands.

Link copied to clipboard
open override fun makePipedHeredoc(content: String, pipeToCmd: String): String

Command building combinator to make heredocs and then have a command to pipe the heredoc into. Usually to be registed into a Var or piped into other commands.

Link copied to clipboard
open override fun print(content: String): String

Command to print content into the console.

Link copied to clipboard
open operator override fun String.rangeTo(rest: String): String

Command building combinator to concat different parts of the command with proper spacing.

Link copied to clipboard
private fun viewCmd(block: MutableList<String>.() -> Unit): String

Helper method for generating a view of the internal representation of the commands.