API Reference
ComposableCommands module
ComposableCommands.LongOption — TypeLongOption(name::String, value)Represent a long option associated with a command.
ComposableCommands.LongFlag — TypeLongFlag(name::String)Represent a long flag associated with a command.
ComposableCommands.ShortOption — TypeShortOption(name::String, value)Represent a short option associated with a command.
ComposableCommands.ShortFlag — TypeShortFlag(name::String)Represent a short flag associated with a command.
ComposableCommands.AndCommands — TypeAndCommands(a::AbstractCommand, b::AbstractCommand)Represent a conjunction of two commands (i.e., both commands are executed).
ComposableCommands.OrCommands — TypeOrCommands(a::AbstractCommand, b::AbstractCommand)Represent a disjunction of two commands (i.e., either command is executed).
ComposableCommands.RedirectedCommand — TypeRedirectedCommand(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. Ifsourceis aString, it represents the filename of the file from which to read. Ifsourceis a subtype ofAbstractCommand, it represents the command whose output is to be redirected.destination: The destination to which to redirect. Ifdestinationis aString, it represents the filename of the file to which to write. Ifdestinationis a subtype ofAbstractCommand, it represents the command that takes the redirected output as input.
ComposableCommands.Command — TypeCommand(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.
ComposableCommands.interpret — Functioninterpret(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)
Cmdinterpret(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.CmdRedirectinterpret(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.AndCmdsinterpret(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