Skip to content

Commit

Permalink
Move precondition checks to the actual command
Browse files Browse the repository at this point in the history
help_now crashes the cli with `error preconditions failed`

Fixes #1
  • Loading branch information
Malinskiy committed Aug 30, 2019
1 parent cac687d commit 60ae665
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions lib/spielbash/view/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ def which(cmd)
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'
Expand All @@ -42,6 +34,13 @@ def which(cmd)
c.action do |_, options, _|
script_path = options[:script]
output_path = options[:output]

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')

Spielbash::RecordInteractor.new().execute(script_path, output_path)
end
end
Expand Down

0 comments on commit 60ae665

Please sign in to comment.