Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A Shell wrapper that is full of syntactic sugar
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
tasks
tests
.gitignore
.rvmrc
Gemfile
Gemfile.lock
README.md
Rakefile

README.md

Darky

Darky is a smart and flexible shell wrapper that aims for simplicity and packed with all the syntactic sugar you need.

Status

Darky is still in an extremely early stage of development and may be missing a lot of features.

Syntax

 # Block
 Darky.new do |shell|
  shell['/usr/local'] do
    shell.exec "pwd" # "/usr/local"
  end
  shell.exec "pwd" # "/home/shuki"

  shell = shell['/usr/local']
  shell.exec "pwd" # "/usr/local"

  shell.chdir "/tmp" do
    shell.exec "pwd" # "/tmp"
  end
  shell.exec "pwd" # "/usr/local"

  shell.chdir! "/tmp"
  shell.exec "pwd" # "/tmp"

  shell.ls_lrth # call exec("ls -lrth")
 end

 # Instance approach
 shell = Darky.new(:dir => '/tmp')
 shell.exec "pwd" # /tmp

 # By using Darky.new.async, you can make calls asynchronously.
 obj = shell.async.ln_lrth # run `ls -lrth`
 obj.on_success { |resp| $stdout.puts resp.out }
 obj.on_failure { |resp| $stderr.puts resp.err }

 # Fast chdir
 Darky['/tmp'] do |shell|
  shell.pwd # "/tmp" 
 end

 # Schedules
 Darky['/usr/shuki'].every 10.seconds do |shell|
  shell.exec("/usr/bin/ruby -e 'puts \"Hello\"' ")
 end

 Darky['/usr/shuki'].every 24.hours do |shell|
  puts shell.pwd
 end

TODO

  • use send method to send commands + think about arguments
  • can be included to any class
  • support environment variables (sticky or non-sticky)
  • support eventmachine
  • support threads
  • support celluloid.io
  • support threads
  • support callbacks success, failure, or just .callback
  • exec without fork
  • support sudo prompt
  • exceptions - failure, permission denied
  • internal / external logger
  • logger should support filters, like ignore /shuki.*/
  • open4/3
  • timeout + handler
  • kill when using proxy object
  • save the state when using custom client
  • can be included into class - to describe a service
  • scheduler
Something went wrong with that request. Please try again.