Sha256: ac925fc09c31391744ead9bf742997f8cc5f7b4ee9a6ad45498ca1fb75d0a619

Contents?: true

Size: 1.26 KB

Versions: 3

Compression:

Stored size: 1.26 KB

Contents

require "thor"

module Munge
  module Cli
    class Dispatch < Thor
      include Thor::Actions

      def self.source_root
        File.expand_path("../../../../seeds", __FILE__)
      end

      desc "init PATH", "Create new site at PATH"
      def init(path)
        directory ".", path
      end

      desc "build", "Build in current directory"
      method_option :reporter, desc: "Set reporter", default: "Default", type: :string
      method_option :dry_run, desc: "Run without writing files", default: false, type: :boolean
      def build
        Commands::Build.new(bootloader, symbolized_options)
      end

      desc "view", "View built files"
      method_option :port, aliases: "-p", desc: "Set port", default: 7000, type: :numeric
      method_option :host, aliases: "-h", desc: "Set host", default: "0.0.0.0", type: :string
      def view
        Commands::View.new(bootloader, symbolized_options)
      end

      desc "version", "Print version"
      map %w(-v --version) => "version"
      def version
        puts "munge #{Munge::VERSION}"
      end

      private

      def bootloader
        Munge::Bootloader.new(root_path: destination_root)
      end

      def symbolized_options
        Munge::Util::SymbolHash.deep_convert(options)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
munge-0.9.0 lib/munge/cli/dispatch.rb
munge-0.8.0 lib/munge/cli/dispatch.rb
munge-0.7.1 lib/munge/cli/dispatch.rb