Sha256: fe28e30c9ce655223679b41cdf54ad9be394b53766b72be22802b278780c1f90

Contents?: true

Size: 1.14 KB

Versions: 8

Compression:

Stored size: 1.14 KB

Contents

module Troy
  class Cli < Thor
    check_unknown_options!

    def self.exit_on_failure?
      true
    end

    def initialize(args = [], options = {}, config = {})
      if config[:current_task].name == "new" && args.empty?
        raise Error, "The site path is required. For details run: troy help new"
      end

      super
    end

    desc "new SITE", "Generate a new site structure"
    def new(path)
      generator = Generator.new
      generator.destination_root = path
      generator.invoke_all
    end

    desc "export", "Generate static files"
    def export
      Troy::Site.new(Dir.pwd).export
    end

    desc "watch", "Watch and auto export site"
    def watch
      Troy::Site.new(Dir.pwd).export
    end

    desc "version", "Display Troy version"
    map %w(-v --version) => :version
    def version
      say "Troy #{Troy::VERSION}"
    end

    desc "server", "Start a server"
    option :port, :type => :numeric, :default => 9292, :aliases => "-p"
    def server
      handler = Rack::Handler::Thin rescue Rack::Handler::WEBrick
      handler.run Troy::Server.new(File.join(Dir.pwd, "public")), :Port => options[:port]
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
troy-0.0.15 lib/troy/cli.rb
troy-0.0.14 lib/troy/cli.rb
troy-0.0.13 lib/troy/cli.rb
troy-0.0.12 lib/troy/cli.rb
troy-0.0.11 lib/troy/cli.rb
troy-0.0.10 lib/troy/cli.rb
troy-0.0.9 lib/troy/cli.rb
troy-0.0.8 lib/troy/cli.rb