Sha256: 5b1f9365e4c1edd41616b4e87ad1bc7d4783f4cb1fa1566be28f090348ced923
Contents?: true
Size: 1.07 KB
Versions: 2
Compression:
Stored size: 1.07 KB
Contents
module Wordless module CLIHelper extend ActiveSupport::Concern included do %i[say run].each do |sym| define_method sym do |*args| thor.send(sym, *args) end private sym end end private def thor raise NotImplementedError, "Including class must provide a thor instance object" end def info(message) log_message message end def error(message) log_message message, :red exit end def success(message) log_message message, :green end def warning(message) log_message message, :yellow end def ensure_wp_cli_installed! error("Cannot continue: WP-CLI is not installed.") unless wp_cli_installed? end def run_command(command) system("#{command} >>#{void} 2>&1") end def wp_cli_installed? run_command("which wp") end def log_message(message, color = nil) say message, color end def void /msdos|mswin|djgpp|mingw/.match? RbConfig::CONFIG['host_os'] ? 'NUL' : '/dev/null' end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
wordless-2.1.0 | lib/wordless/cli_helper.rb |
wordless-2.0.0 | lib/wordless/cli_helper.rb |