Xamal.Commands.Base (xamal v0.3.1)

Copy Markdown View Source

Base module for building shell commands.

Commands are represented as lists of string/atom parts that get joined with spaces when executed. Composition helpers (combine, pipe, chain, etc.) join multiple commands with shell operators.

This matches Kamal's command-building pattern.

Summary

Functions

Join with || (run second if first fails).

Join with >> (append to file).

Join multiple commands with ; (run sequentially regardless of exit code).

Join multiple commands with && (all must succeed).

Create a mkdir -p command.

Join multiple commands with | (pipe stdout).

Create an rm -r command.

Create an rm command.

Wrap a command in sh -c '...' for safe subshell execution.

Convert command parts to a single shell string.

Join with > (write/overwrite file).

Create an xargs-prefixed command.

Functions

any(commands)

Join with || (run second if first fails).

append(commands)

Join with >> (append to file).

chain(commands)

Join multiple commands with ; (run sequentially regardless of exit code).

combine(commands)

Join multiple commands with && (all must succeed).

make_directory(path)

Create a mkdir -p command.

pipe(commands)

Join multiple commands with | (pipe stdout).

remove_directory(path)

Create an rm -r command.

remove_file(path)

Create an rm command.

shell(command_parts)

Wrap a command in sh -c '...' for safe subshell execution.

to_command_string(parts)

Convert command parts to a single shell string.

write(commands)

Join with > (write/overwrite file).

xargs(command_parts)

Create an xargs-prefixed command.