<commit_before>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<commit_msg>Added version command.<commit_after>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
{'fraction_non_alphanumeric': 0.11989342806394317, 'fraction_numerical': 0.003552397868561279, 'mean_word_length': 2.6338709677419354, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3573425', 'n_tokens_mistral': 714, 'n_tokens_neox': 687, 'n_words': 210}