Module implements wrapper for execution of the external command-line applications.
Types
ShellArg = object cmd*: string ## Shell command argument string kind*: ShellArgKind
- Source Edit
ShellArgKind = enum cpkArgument, ## String argument to command cpkTemplated ## Interpolated parameter
- Source Edit
ShellCmd = object bin*: string ## Binary name or absolute path opts*: seq[ShellArg] ## Arguments
- Source Edit
ShellResult = object cmd*: ShellCmd cwd*: string ## Absolute path of initial command execution directory retcode*: int ## Exit code stderr*: string ## Stderr for command stdout*: string ## Stdout for command
- Source Edit
ShInterpolate = Table[string, seq[ShellArg]]
- Source Edit
Procs
func add(cmd: var ShellCmd; arg: ShellArg) {....raises: [], tags: [].}
- Add argument to shell command Source Edit
func add(cmd: var ShellCmd; args: openArray[ShellArg]) {....raises: [], tags: [].}
- Add arguments to shell command Source Edit
func arg(cmd: var ShellCmd; format: string; args: varargs[string]) {. ...raises: [ValueError], tags: [].}
- Source Edit
func args(cmd: var ShellCmd; args: openArray[ShellArg]) {....raises: [], tags: [].}
- Add argument for command Source Edit
func args(cmd: var ShellCmd; args: openArray[string]) {....raises: [], tags: [].}
- Add argument for command Source Edit
func argsToStr(cmd: ShellCmd): seq[string] {....raises: [], tags: [].}
- Get command arguments as list of strings Source Edit
proc exec(cmd: ShellCmd; dir: string = ""; stdin: string = ""; options: set[ProcessOption] = {poUsePath}; maxOutSize: int = 40960 * 1024): ShellResult {. ...raises: [OSError, Exception, IOError], tags: [ExecIOEffect, ReadEnvEffect, RootEffect, WriteIOEffect, ReadIOEffect].}
- Execute shell command. Source Edit
proc exec(cmds: openArray[ShellCmd]; options: set[ProcessOption] = {poUsePath}; maxParallel: int = countProcessors(); dir: string = ""; beforeRunEvent: proc (idx: int) = nil; afterRunEvent: proc (idx: int; p: Process) = nil): seq[ShellResult] {. ...raises: [OSError, Exception, IOError], tags: [ExecIOEffect, ReadEnvEffect, RootEffect, ReadIOEffect, WriteIOEffect].}
- Execute multiple shell commands in paralell, return full list of results in the same order as the original commands. Source Edit
func interpolate(cmd: ShellCmd; map: openArray[(string, seq[string])]): ShellCmd {. ...raises: [KeyError], tags: [].}
- Source Edit
func interpolate(cmd: ShellCmd; map: ShInterpolate): ShellCmd {. ...raises: [KeyError], tags: [].}
- Source Edit
func interpolate(part: ShellArg; map: ShInterpolate): seq[ShellArg] {. ...raises: [KeyError], tags: [].}
- Replace all templated arguments with appropriate substitutions. Source Edit
func shArg(arg: string): ShellArg {....raises: [], tags: [].}
- Create non-templated shell command argument Source Edit
func shell(bin: string; args: openArray[ShellArg]): ShellCmd {....raises: [], tags: [].}
- Create shell command with given bin and it's arguments Source Edit
func shell(bin: string; args: openArray[string] = @[]): ShellCmd {....raises: [], tags: [].}
- Create shell command with given bin and it's arguments Source Edit
func shSub(arg: string): ShellArg {....raises: [], tags: [].}
- Create templated shell command argument Source Edit
func shSub(cmd: var ShellCmd; subs: openArray[string]) {....raises: [], tags: [].}
- Add templated shell command arguments to a command Source Edit
proc start(cmd: ShellCmd; dir: string = ""; options: set[ProcessOption] = {poUsePath}): Process {. ...raises: [OSError, Exception], tags: [ExecIOEffect, ReadEnvEffect, RootEffect].}
- Source Edit