lib/spielbash/view/cli.rb in spielbash-0.1.1 vs lib/spielbash/view/cli.rb in spielbash-0.1.2

- old
+ new

@@ -8,11 +8,30 @@ program_desc 'Tool to automate bash movie-making with asciinema. Be the Spielberg of bash' desc 'Be verbose' switch [:v, :verbose] - # pre do |global_options, command, options, args| - # end + # Cross-platform way of finding an executable in the $PATH. + # + # which('ruby') #=> /usr/bin/ruby + def which(cmd) + exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : [''] + ENV['PATH'].split(File::PATH_SEPARATOR).each do |path| + exts.each {|ext| + exe = File.join(path, "#{cmd}#{ext}") + return true if File.executable?(exe) && !File.directory?(exe) + } + end + false + end + + pre do |global_options, command, options, args| + help_now!('pgrep is not installed!') unless which('pgrep') + help_now!('docker is not installed!') unless which('docker') + help_now!('tmux is not installed!') unless which('tmux') + help_now!('resize is not installed!') unless which('resize') + help_now!('asciinema is not installed!') unless which('asciinema') + end desc 'Create a recording' command :record do |c| c.desc 'Script file path' c.flag [:script] \ No newline at end of file