API Reference

ComposableCommands module

ComposableCommands.RedirectedCommandType
RedirectedCommand(source, destination)

Wrap an AbstractCommand and a file (String).

It allows output redirection from a command to a file or input redirection from a file to a command. The redirection is specified by the RedirectedCommand's source and destination parameters.

Arguments

  • source: The source from which to redirect. If source is a String, it represents the filename of the file from which to read. If source is a subtype of AbstractCommand, it represents the command whose output is to be redirected.
  • destination: The destination to which to redirect. If destination is a String, it represents the filename of the file to which to write. If destination is a subtype of AbstractCommand, it represents the command that takes the redirected output as input.
source
ComposableCommands.CommandType
Command(name, parameters, arguments, subcommands)

Represent a command to be executed, with associated flags, options, arguments, and subcommands.

Arguments

  • name::String: the name of the command.
  • parameters: an iterable of flags and options.
  • arguments::Vector{String}: any arguments to the command.
  • subcommands::Vector{AbstractCommand}: any subcommands to be executed in conjunction with the main command.
source
ComposableCommands.interpretFunction
interpret(command::Command)

Translate a Command object into a Cmd that can be executed.

Examples

julia> c = Command("ls", [LongFlag("all")], [], []);

julia> cmd = interpret(c)
`ls --all`

julia> typeof(cmd)
Cmd
source
interpret(command::RedirectedCommand)

Translate a RedirectedCommand object into a Base.CmdRedirect that can be executed, considering the redirection.

Examples

julia> r = RedirectedCommand(Command("ls", [], [], []), "output.txt");

julia> cmd = interpret(r)
pipeline(`ls`, stdout>Base.FileRedirect("output.txt", false))

julia> typeof(cmd)
Base.CmdRedirect

julia> r = RedirectedCommand(".zshrc", Command("cat", [], [], []));

julia> cmd = interpret(r)
pipeline(`cat`, stdin<Base.FileRedirect(".zshrc", false))

julia> typeof(cmd)
Base.CmdRedirect
source
interpret(commands::AndCommands)

Translate an AndCommands object into a Base.AndCmds that can be executed, considering the conjunction.

Examples

julia> c1 = Command("ls", [], [], []);

julia> c2 = Command("pwd", [], [], []);

julia> ac = AndCommands(c1, c2);

julia> cmd = interpret(ac)
`ls` & `pwd`

julia> typeof(cmd)
Base.AndCmds
source
interpret(commands::OrCommands)

Translate an OrCommands object into a Base.OrCmds that can be executed, considering the disjunction.

Examples

julia> c1 = Command("ls", [], [], []);

julia> c2 = Command("pwd", [], [], []);

julia> oc = OrCommands(c1, c2);

julia> cmd = interpret(oc)
pipeline(`ls`, stdout=`pwd`)

julia> typeof(cmd)
Base.OrCmds
source