shell

Provisional fork until the original restarts: https://github.com/dmytro/shell.cr - CHANGES: support crystal-0.25, added Shell::Seq - (breaking-change): respect Process attributes like chdir, type of status shell monadic-interface
0.1.0 released
maiha/shell.cr
4 2
maiha

shell

Small simplistic helper class for executing shell commands in Crystal:

  • run command,
  • exit if it fails,
  • return STDOUT of the command;
  • optionally
    • allow to ignore failure
    • return STDERR of failed command.

Installation

Add this to your application's shard.yml:

dependencies:
  shell:
    github: dmytro/shell.cr

Usage

require "shell"

Output of the shell command is available through #stdout and #stderr methods, numeric value of the exit status returned by the function #run.

Simplest usage of the #run method:

puts Shell.run("ls").stdout

If command fails Shell raises exception, but this behaviour can be overridden by fail_on_error variable:

puts Shell.run("command_with_non_zero_status", fail_on_error: false).stderr

Contributing

  1. Fork it ( https://github.com/dmytro/shell/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

  • dmytro Dmytro Kovalov - creator, maintainer
shell:
  github: maiha/shell.cr
  version: ~> 0.1.0
License MIT
Crystal none

Authors

Dependencies 0

Development Dependencies 1

  • spec2 ~> 0.9
    {'github' => 'waterlink/spec2.cr', 'version' => '~> 0.9'}

Dependents 2

Last synced .
search fire star recently