Sha256: 770f08cbd51aeb838ed793cb30caf87c1d4dbb832c92dfa2db4c87d445bd8e48

Contents?: true

Size: 1.79 KB

Versions: 1

Compression:

Stored size: 1.79 KB

Contents

module Wordmove
  class CLI < Thor
    map %w[--version -v] => :__print_version

    desc "--version, -v", "Print the version"
    def __print_version
      puts Wordmove::VERSION
    end

    desc "init", "Generates a brand new Movefile"
    def init
      Wordmove::Generators::Movefile.start
    end

    shared_options = {
      wordpress:   { aliases: "-w", type: :boolean },
      uploads:     { aliases: "-u", type: :boolean },
      themes:      { aliases: "-t", type: :boolean },
      plugins:     { aliases: "-p", type: :boolean },
      languages:   { aliases: "-l", type: :boolean },
      db:          { aliases: "-d", type: :boolean },

      verbose:     { aliases: "-v", type: :boolean },
      simulate:    { aliases: "-s", type: :boolean },
      environment: { aliases: "-e" },
      config:      { aliases: "-c" },

      no_adapt:    { type: :boolean },
      all:         { type: :boolean }
    }

    no_tasks do
      def handle_options(options)
        %w(wordpress uploads themes plugins languages db).map(&:to_sym).each do |task|
          if options[task] || options[:all]
            yield task
          end
        end
      end
    end

    desc "pull", "Pulls WP data from remote host to the local machine"
    shared_options.each do |option, args|
      method_option option, args
    end
    def pull
      deployer = Wordmove::Deployer::Base.deployer_for(options)
      handle_options(options) do |task|
        deployer.send("pull_#{task}")
      end
    end

    desc "push", "Pushes WP data from local machine to remote host"
    shared_options.each do |option, args|
      method_option option, args
    end
    def push
      deployer = Wordmove::Deployer::Base.deployer_for(options)
      handle_options(options) do |task|
        deployer.send("push_#{task}")
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wordmove-1.3.0 lib/wordmove/cli.rb