Sha256: f7cad7a5e056683e506bd12243a661302b749dd2fe62b1405ada45c476ffe0ea

Contents?: true

Size: 963 Bytes

Versions: 8

Compression:

Stored size: 963 Bytes

Contents

module WordPressTools
  module CLIHelper
    include Thor::Actions

    def info(message)
      say message
    end

    def error(message)
      say message, :red
      exit
    end

    def success(message)
      say message, :green
    end

    def warning(message)
      say message, :yellow
    end

    def git_installed?
      run_command("git --version")
    end

    def unzip(file, destination, extra_options = '')
      run_command("unzip #{extra_options} #{file} -d #{destination}")
    end

    def move_command(from, to, need_sudo = false)
      sudo = 'sudo' if need_sudo
      "#{sudo} mv '#{from}' '#{to}'"
    end

    def executable_bit_command(path, need_sudo = false)
      sudo = 'sudo' if need_sudo
      "#{sudo} chmod 755 '#{path}'"
    end

    def void
      RbConfig::CONFIG['host_os'] =~ /msdos|mswin|djgpp|mingw/ ? 'NUL' : '/dev/null'
    end

    def run_command(command)
      system("#{command} >>#{void} 2>&1")
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
wordpress_tools-1.4.1 lib/wordpress_tools/cli_helper.rb
wordpress_tools-1.4.0 lib/wordpress_tools/cli_helper.rb
wordpress_tools-1.3.0 lib/wordpress_tools/cli_helper.rb
wordpress_tools-1.2.0 lib/wordpress_tools/cli_helper.rb
wordpress_tools-1.1.3 lib/wordpress_tools/cli_helper.rb
wordpress_tools-1.1.2 lib/wordpress_tools/cli_helper.rb
wordpress_tools-1.1.1 lib/wordpress_tools/cli_helper.rb
wordpress_tools-1.1.0 lib/wordpress_tools/cli_helper.rb