class Marv::CLI::Base

Public Class Methods

source_root() click to toggle source

Set layouts root path

# File lib/marv/cli/base.rb, line 9
def self.source_root
  ::File.expand_path(::File.join(Marv.root, 'layouts'))
end

Public Instance Methods

ask_input(text, color=nil, *args) click to toggle source

Ask for user input

# File lib/marv/cli/base.rb, line 48
def ask_input(text, color=nil, *args)
  self.ask("#{text}", color, *args)
end
ask_option(text, color=nil, *args) click to toggle source

Ask for option value

# File lib/marv/cli/base.rb, line 53
def ask_option(text, color=nil, *args)
  self.ask("  #{text}", color, *args)
end
exec_exixts?(name) click to toggle source

Check if executable exists

# File lib/marv/cli/base.rb, line 73
def exec_exixts?(name)
  `which #{name}`.start_with?('/')
end
said_change?(text, *args) click to toggle source

Ask to change options

# File lib/marv/cli/base.rb, line 58
def said_change?(text, *args)
  self.yes?("ยป #{text}", :cyan, *args)
end
said_no?(text, *args) click to toggle source

Ask for no answer

# File lib/marv/cli/base.rb, line 68
def said_no?(text, *args)
  self.no?("#{text}", :yellow, *args)
end
said_yes?(text, *args) click to toggle source

Ask for yes answer

# File lib/marv/cli/base.rb, line 63
def said_yes?(text, *args)
  self.yes?("#{text}", :cyan, *args)
end
say_empty(lines=1) click to toggle source

Print an empty message

# File lib/marv/cli/base.rb, line 15
def say_empty(lines=1)
  (1..lines).each { self.say('') }
end
say_error(text, message=nil, space_below=true, space_above=false) click to toggle source

Print error message

# File lib/marv/cli/base.rb, line 27
def say_error(text, message=nil, space_below=true, space_above=false)
  say_message(text, false, space_above, :red)
  say_message(message, space_below, false) unless message.nil?
end
say_info(text, space_below=false, space_above=false) click to toggle source

Print info message

# File lib/marv/cli/base.rb, line 33
def say_info(text, space_below=false, space_above=false)
  say_message(text, space_below, space_above, :cyan)
end
say_message(text, space_below=true, space_above=false, color=nil) click to toggle source

Print general message

# File lib/marv/cli/base.rb, line 20
def say_message(text, space_below=true, space_above=false, color=nil)
  self.say_empty if space_above
  self.say("#{text}", color)
  self.say_empty if space_below
end
say_success(text, space_below=true, space_above=false) click to toggle source

Print success message

# File lib/marv/cli/base.rb, line 43
def say_success(text, space_below=true, space_above=false)
  say_message(text, space_below, space_above, :green)
end
say_warning(text, space_below=true, space_above=false) click to toggle source

Print warning message

# File lib/marv/cli/base.rb, line 38
def say_warning(text, space_below=true, space_above=false)
  say_message(text, space_below, space_above, :yellow)
end