exec

Basic Shell-like, async by default, command execution with no shell interpreter invocation process
0.3.5 released
j8r/exec.cr
4
Julien Reichardt

This repo seems to be no longer available at j8r/exec.cr.

Git synchronization failed . Last successful sync was .

Help find it again! … or have it archived.

Exec

Thin Process wrapper for simple execution of programs with arguments

Installation

Add the dependency to your shard.yml:

dependencies:
  exec:
    github: j8r/exec.cr

Usage

Methods

#out(strict = false) : String: Return the output (stdout) of the process as a String if exited normally with an exit code of 0, else return the error (stderr) or raise the error when strict = true

#output : String: Return the stdout

#error : String: Return the stderr

Other methods are available, forwarded from Process::Status

Examples

Exec.new("/bin/true").success? # true

# Shell-like syntax
Exec.new("ls /tmp -l").exit_status # 0
# Most efficient syntax
Exec.new("/bin/ls", ["/tmp", "-l"]).exit_status # 0
# Other supported syntaxes
Exec.new("/bin/ls /tmp -l")
Exec.new("/bin/ls", "/tmp -l")
Exec.new("ls", "/tmp -l")

Exec.new("/bin/pwd", args: "", dir: "/tmp").out # "/tmp\n"

License

Copyright (c) 2017 - 2018 Julien Reichardt - ISC License

exec:
  github: j8r/exec.cr
  version: ~> 0.3.5
License ISC
Crystal none

Authors

Dependencies 0

Development Dependencies 0

Dependents 1

Last synced .
search fire star recently