Source Code

This modules provides functions to execute commands.

The following example will create a task that when called will execute git pull command.

Task updateTask = command("git pull");

command function is a Task wrapper for executeCommand function.

Commands are executed in a synchronous way. This means that both functions will wait for command to exit before returning.

License: [ASL 2.0](http://www.apache.org/licenses/LICENSE-2.0)
Packages
ceylon.build.tasks.commandline

Tasks to execute system commands

Dependencies
ceylon.build.task1.0.0
ceylon.file1.0.0
ceylon.process1.0.0

Tasks to execute system commands

Functions
commandSource Code
shared Task command(String command, Path path = ..., Input? input = ..., Output? output = ..., Error? error = ..., {<String->String>*} environment = ...)

Returns a Task that will run the given command in a new a new process using executeCommand. Returns true if process exit code is 0, false otherwise.

Parameters:
  • command

    The command to be run in the new process, usually a program with a list of its arguments.

  • path = current

    The directory in which the process runs.

  • input = currentInput

    The source for the standard input stream of the process, or null if the standard input should be piped from the current process.

  • output = currentOutput

    The destination for the standard output stream ofthe process, or null if the standard output should be piped to the current process.

  • error = currentError

    The destination for the standard output stream ofthe process, or null if the standard error should be piped to the current process.

  • environment = currentEnvironment

    Environment variables to pass to the process. By default the process inherits the environment variables of the current virtual machine process.

See also: executeCommand
executeCommandSource Code
shared Integer? executeCommand(String command, Path path = ..., Input? input = ..., Output? output = ..., Error? error = ..., {<String->String>*} environment = ...)

Creates and starts a new process, running the given command. Waits for process termination and returns its exit code.

Parameters:
  • command

    The command to be run in the new process, usually a program with a list of its arguments.

  • path = current

    The directory in which the process runs.

  • input = currentInput

    The source for the standard input stream of the process, or null if the standard input should be piped from the current process.

  • output = currentOutput

    The destination for the standard output stream ofthe process, or null if the standard output should be piped to the current process.

  • error = currentError

    The destination for the standard output stream ofthe process, or null if the standard error should be piped to the current process.

  • environment = currentEnvironment

    Environment variables to pass to the process. By default the process inherits the environment variables of the current virtual machine process.

See also: createProcess
exitCodeToOutcomeSource Code
shared Outcome exitCodeToOutcome(Integer exitCode, String command, Path path = ...)

Convert a command exit code into an Outcome.

If exitCode is 0, a successfull outcome will be returned.

If exitCode is not 0, a failure outcome will be returned with information about executed command.

Parameters:
  • path = current