Sha256: 4ab18a865880759e59d258bb2495d93ed7803a8475a013606ce77c0c9fc6c136

Contents?: true

Size: 1 KB

Versions: 7

Compression:

Stored size: 1 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 "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

7 entries across 7 versions & 1 rubygems

Version Path
troy-0.0.7 lib/troy/cli.rb
troy-0.0.6 lib/troy/cli.rb
troy-0.0.5 lib/troy/cli.rb
troy-0.0.4 lib/troy/cli.rb
troy-0.0.3 lib/troy/cli.rb
troy-0.0.2 lib/troy/cli.rb
troy-0.0.1 lib/troy/cli.rb