Skip to content

Commit

Permalink
main: extract [command] into separate method
Browse files Browse the repository at this point in the history
also replace newlines with one spaces
  • Loading branch information
dawidd6 committed Jul 25, 2020
1 parent e2ecc93 commit f5ca97a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions main.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,33 @@ def false?
module Homebrew
module_function

def print_command(*cmd)
puts "[command]#{cmd.join(' ').gsub("\n", ' ')}"
end

def brew(*args)
puts "[command]brew #{args.join(' ')}"
print_command 'brew', *args
return if ENV['DEBUG']

safe_system 'brew', *args
end

def git(*args)
puts "[command]git #{args.join(' ')}"
print_command 'git', *args
return if ENV['DEBUG']

safe_system 'git', *args
end

def read_brew(*args)
puts "[command]brew #{args.join(' ')}"
print_command 'brew', *args
return if ENV['DEBUG']

Utils.safe_popen_read('brew', *args).chomp
end

def read_git(*args)
puts "[command]git #{args.join(' ')}"
print_command 'git', *args
return if ENV['DEBUG']

Utils.safe_popen_read('git', *args).chomp
Expand Down

0 comments on commit f5ca97a

Please sign in to comment.